Answer to Question #210893 in C for genji

Question #210893

Display the largest number of three numbers. Condition is uses only if statement to find the largest number


1
Expert's answer
2021-06-27T14:11:09-0400
#include <stdio.h>


int largest(int x1, int x2, int x3) {
    int largest = x3;


    if (x1 >= x2 && x1 >= x3)
        largest = x1;
    else if (x2 >= x1 && x2 >= x3)
        largest = x2;


    return largest;
}


int main() {
    int a, b, c;
    printf("Enter three integers: ");
    scanf("%d %d %d", &a, &b, &c);
    printf("The lagest value is %d\n", largest(a, b, c));


    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

Fami sherif
14.09.22, 10:37

Like

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS