Write a program to check greatest of 3 numbers.
Answers
Answered by
7
Answer:
The program output is also shown below.
- * C program to find the biggest of three numbers.
- int num1, num2, num3;
- printf("Enter the values of num1, num2 and num3\n");
- scanf("%d %d %d", &num1, &num2, &num3);
- printf("num1 = %d\tnum2 = %d\tnum3 = %d\n", num1, num2, num3);
- if (num1 > num2)
- if (num1 > num3)
Answered by
2
double n1, n2, n3;
printf("Enter three numbers: ");
scanf("%lf %lf %lf", &n1, &n2, &n3);
if (n1 >= n2) {
if (n1 >= n3)
printf("%.2lf is the largest number.", n1);
else
printf("%.2lf is the largest number.", n3);
} else {
if (n2 >= n3)
printf("%.2lf is the largest number.", n2);
else
printf("%.2lf is the largest number.", n3);
}
return 0;
}
Similar questions