14.Write a program in C to find the maximum of three numbers using nested 'if-else' statements.
Purpose:
The purpose of the program to find the maximum of three numbers using nested if-else statements is to offer a humble and effective way to express the largest value among a set of three numbers. This program can be used in various real-life scenarios where comparisons need to be made between multiple values, such as in grading systems, financial analysis, sports analytics, and manufacturing processes. By precisely classifying the maximum value among the given numbers, the program assistances in decision-making processes, resource allocation, and performance evaluation.
Real-life applications:
1. In a student grading system, a program may determine the highest score on three tests to determine the best student in the class.
2. In a financial program, the program can compare the ROI of three different options to determine the most profitable option.
3. In the sports analysis tool, the program can analyze the performance statistics of three athletes to determine the athlete with the highest overall performance.
4. In a manufacturing environment, the program can compare the performance of three different production lines to determine the most efficient and productive line.
a program in C to find the maximum of three numbers using nested if else statements.
/* C language program to find the maximum of three numbers using nested if else statements.*/
#include <stdio.h>
int main()
{
int num1, num2, num3;
printf("Enter three numbers:\n ");
scanf("%d %d %d", &num1, &num2, &num3);
if (num1 >= num2) {
if (num1 >= num3) {
printf("Maximum number is: %d\n", num1);
} else {
printf("Maximum number is: %d\n", num3);
}
} else {
if (num2 >= num3) {
printf("Maximum number is: %d\n", num2);
} else {
printf("Maximum number is: %d\n", num3);
}
}
return 0;
}
Output
Enter three numbers:
90
15
20
Maximum number is:90