Display the largest number of three numbers. Condition is uses only if statement to find the largest number
#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;
}
Comments
Like
Leave a comment