Question

You have three integers (num1, num2, num3). Write an if…else statement that given these 3 integers...

You have three integers (num1, num2, num3). Write an if…else statement that given these 3 integers prints the largest on

0 0
Add a comment Improve this question Transcribed image text
Answer #1
#include <stdio.h> 
int main() 
{ 
        int A, B, C; 

        printf("Enter three numbers: "); 
        scanf("%d %d %d", &A, &B, &C); 

        if (A >= B) { 
                if (A >= C) 
                        printf("%d is the largest number.", A); 
                else
                        printf("%d is the largest number.", C); 
        } 
        else { 
                if (B >= C) 
                        printf("%d is the largest number.", B); 
                else
                        printf("%d is the largest number.", C); 
        } 

        return 0; 
} 

Output :-

Enter three numbers: 2 5 3 5 is the largest number.

-------------------------------------------------------

THANK YOU

Add a comment
Know the answer?
Add Answer to:
You have three integers (num1, num2, num3). Write an if…else statement that given these 3 integers...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Given the following code… var num1 = 31; var num2 = 96; var num3 = 22;...

    Given the following code… var num1 = 31; var num2 = 96; var num3 = 22; var temp = num2; num3 = temp + num1; num1 = num1 + num3 var num4 = num3 + 11; num2 = num2 + num4; var ans = num1 + num2 + num3; What is the final value that is assigned to ‘ans’?

  • Consider the mathematical expression (num1 + num2) × (num3 − num4). We have been asked to...

    Consider the mathematical expression (num1 + num2) × (num3 − num4). We have been asked to replace num1, num2, num3 and num4 by numbers between 1 and 35, i.e. numbers from the set {1, . . . , 35}, so that after substituting these numbers in place of num1, num2, num3 and num4, the evaluation of the expression using PEDMAS leads to an odd positive integer. Find the number of ways in which this can be done. For example, one...

  • Use assembly language to write a complete program that will input values fornum1 ,num2 and num3...

    Use assembly language to write a complete program that will input values fornum1 ,num2 and num3 and display the value of the expression ( (num1 ^ 3) * num2 + 5 * ( num2 ^ 2) ) / num3. assume that the user enters only numbers that are greater than zero and the calculation never exceed 4 bytes size. Sample run: num1 = 1 num2 = 2 num3 = 3 ((num1 ^ 3) * num2 + 5 * ( num2...

  • Java Programming Write a program called “LargestNumber”, that compares below three numbers and prints out the...

    Java Programming Write a program called “LargestNumber”, that compares below three numbers and prints out the largest number. Num1 = 10, Num2-15, Num3=20. 1. You must use “If/else” logical statement to compare the three numbers.

  • c++ 3- What is the output of the following pseudocode, where num1 , num2 , and...

    c++ 3- What is the output of the following pseudocode, where num1 , num2 , and num3 are integer variables? num1 = 5 num2 = 1 num3 = 4 aQueue.enqueue(num2) aQueue.enqueue(num3) aQueue.dequeue() aQueue.enqueue(num1 - num2) num1 = aQueue.peek() aQueue.dequeue() num2 = aQueue.peek() aQueue.dequeue() cout << num2 << " " << num1 << " " << num3 << endl

  • C++ Write a program that prompts the user to enter two positive integers: num1 and num2....

    C++ Write a program that prompts the user to enter two positive integers: num1 and num2. - Validate that num1 is less than num2 and that both numbers are positive. If any of these conditions are not met, allow the user to re-enter num1 and num2 until the input is determined valid. - For all integers from num1 through num2, print the word keyboard if the current integer is divisible by 2 and print the word mouse if the current...

  • Given following method, public static double getQuotient (int num1, int num2){ return num1/(double) num2; } Write...

    Given following method, public static double getQuotient (int num1, int num2){ return num1/(double) num2; } Write Java statement to invoke the method.

  • Question 3 (1 point) Question 3) METHODs to our Madness: Use the pseudocode methods below to...

    Question 3 (1 point) Question 3) METHODs to our Madness: Use the pseudocode methods below to answer the questions starting on the next page. FIRST METHOD: COMMENT parameters should be integers METHOD largestValue(parameters: num1, num2) BEGIN             IF(num1 >= num2) THEN result ← num1 ELSE result ← num2             ENDIF END largestValue SECOND METHOD: COMMENT parameters should be doubles METHOD largestValue(parameters: num1, num2) BEGIN             IF(num1 >= num2) THEN result ← num1 ELSE result ← num2             ENDIF             RETURN...

  • So the assignment is to write a program that have the user entered 3 numbers and...

    So the assignment is to write a program that have the user entered 3 numbers and than it will sort it by ascending order. Here are the code I wrote, but it won't compiled and I kept on getting an error message "Using uninitiazed memory" for all the variables. Can someone please help take a look and see whats going on? #include <iostream> using namespace std; int main() { //variables int num1, num2, num3; int lowest, middle, highest; //user inputs...

  • Max and Min Number Codes

    How can I write a program whose inputs are three integers, and whose outputs are the largest of the three values and the smallest of the three values. As an example, if the input is 7 15 3, the output is:largest: 15 smallest: 3I want a program that will define and call two functions:Function LargestNumber(integer num1, integer num2, integer num3) returns integer largestNumFunction SmallestNumber(integer num1, integer num2, integer num3) returns integer smallestNum

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT