1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Digiron [165]
4 years ago
12

Making Decisions Programming Challenges 1. Minimum/Maximum Write a program that asks the user to enter two numbers. The program

should use the conditional operator to determine which number is the smaller and which is the larger?
Computers and Technology
1 answer:
Bas_tet [7]4 years ago
3 0

Answer:

int main()

{

   int a,b,max,min;

   cout<<"Enter 2 numbers\n";

   cin>>a>>b;    //asking numbers from user

   max= a>b ? a : b;   //using conditional operator to find larger

   min= a>b ? b : a;    //using conditional operator to find smaller

   cout<<"\nLarger is "<<max;

   cout<<"\nSmaller is "<<min;

   return 0;

}

OUTPUT :

Enter 2 numbers

56

34

Larger is 56

Smaller is 34

Explanation:

  • In the above program, first user is asked to enter 2 numbers which needs to be compared.
  • Conditional operator - This operator contains syntax - (condition ? true : false) . This is a ternary operator in which first operand checks the condition and if its true second operand is returned otherwise third is returned.
  • Then conditional operator is used twice first to find larger number and then smaller.
  • At last both numbers are printed.
You might be interested in
Pls answer this
trapecia [35]

Answer:

It looks like an Acme thread.

Explanation:

5 0
3 years ago
When connecting past and present issues, it is best to follow a series of steps. Which step is missing from the pattern? 1. Iden
Evgen [1.6K]

Establish Cause & Effect

4 0
3 years ago
How do I cite a website?
Mila [183]

Last, First M. “Article Title.”Website Title. Website Publisher, Date Month Year Published. Web. Date Month Year Accessed.


3 0
4 years ago
Read 2 more answers
What are the important points
LUCKY_DIMON [66]

Answer:

You must evaluate information

Explanation:

The first step to thinking critically is to accept information only after evaluating it. Whether it's something read or heard, critical thinkers strive to find the objective truth. In doing this, these employees evaluate by considering possible challenges and solutions. This process of vetting new information and considering outcomes is called evaluation.

6 0
3 years ago
4.2: Roman Numeral Converter
dalvyx [7]

Answer:

1 I

2 II

3 III

4 IV

5 V

6 VI

7 VII

8 VIII

9 IX

10 X

6 0
3 years ago
Other questions:
  • Email applications can either be local email client programs or web-based applications. Which application is an example of a loc
    13·2 answers
  • What is the purpose of using SmartArt Graphics and what is one way you can use SmartArt Graphics in your presentation(s)?
    11·1 answer
  • To always see the header row with scrolling through long worksheets, you would use the ______ command.
    8·1 answer
  • If you have a database of books in the library and you would like to find all books published after January 1, 2008, what criter
    7·1 answer
  • Can some one help me i do not now how to give a BRANLEST. if you help i will give you one BRANLEST.
    7·2 answers
  • What is a header row?
    8·1 answer
  • Calculate the value of z. Given v=4, w=5, x=8, y=2z= (v+ w) * x / y;print (“value of z is “, z)
    8·1 answer
  • Your connection to this site is not secure how to fix.
    15·1 answer
  • During the POST process, the BIOS uses two (2) different ways to notify you of a problem, Error beep codes and error messages, e
    10·1 answer
  • Which sql keyword is used to retrieve a minimum value from an attribute in a table
    7·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!