Source Code
// 11. Program to find the largest among three numbers
// Arpan Das - CST 2nd Year (VOCLET)
#include <stdio.h>
//#include <conio.h>
//#include <stdlib.h>
void main () {
int a, b, c;
//int r1, r2;
//clrscr();
//system("cls");
printf("\t\t..:: find all roots of a quadratic equation ::..\n\n");
printf("Enter any three numbers: ");
scanf("%d%d%d", &a, &b, &c);
// process one
if (a > b && a > c) printf("\n%d is the largest number.", a);
else if (b > c) printf("\n%d is the largest number.", b);
else printf("\n%d is the largest number.", c);
// proces two
/*if (a > b) {
if (a > c) {
printf("\n%d is the largest.", a);
}
} else {
if (b > c) {
printf("\n%d is the largest.",b);
} else {
printf("\n%d is the largest.",c);
}
} */
// process three
/*r1 = a > b ? a : b;
r2 = r1 > c ? r1 : c;
printf("%d is the largest", (a > b ? a : b) > c ? (a > b ? a : b) : c);*/
// process four
// printf("%d is the largest", (a > b ? a : b) > c ? (a > b ? a : b) : c);
//getch();
}
Output
..:: find all roots of a quadratic equation ::..
Enter any three numbers: 4 8 3
8 is the largest number.