Programming Examples

Write a program to detect the largest number out of five numbers and display it


Write a program to detect the largest number out of five numbers and display it?

Solution

#include<stdio.h>
#include<process.h>
void main()
{
int a,b,c,d,e,sum=0,i;
clrscr();
printf(“\nEnter Five numbers :”);
scanf(“%d %d %d %d %d”,&a,&b,&c,&d,&e);
sum=a+b+c+d+e;
for(i=sum; i<=sum;i–-)
{
 if(i==a || i==b || i==c || i==d || i==e)
 {
 printf(“The Largest Number : %d”,i);
 exit(0);
 }
}
}
▶ RUN

Output/ Explanation:

OUTPUT:

Enter Five numbers : 5 2 3 7 3

The Largest Number : 7

Latest Current Affairs 2025 Online Exam Quiz for One day Exam Online Typing Test CCC Online Test Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Online MBA 2 years Online MCA Online BCA Best Website and Software Company in Allahabad