C Program to find the Biggest of Five Numbers

Below is an example of a C program that finds the largest among five numbers. The program compares each number with the current maximum and updates the maximum whenever a larger number is encountered.

Method 1 :

#include<stdio.h>
#include<conio.h>
main()
{
int a,b,c,d,e;
printf(“Enter First the Number : “);
scanf(“%d”,&a);
printf(“Enter Second the Number : “);
scanf(“%d”,&b);
printf(“Enter Third the Number : “);
scanf(“%d”,&c);
printf(“Enter Foruth the Number : “);
scanf(“%d”,&d);
printf(“Enter Fifth the Number : “);
scanf(“%d”,&e);
if((a>b)&&(a>c)&&(a>d)&&(a>e))
{
printf(“%d is the Biggest Number.”,a);
}
else if((b>a)&&(b>c)&&(b>d)&&(b>e))
{
printf(“%d is the Biggest Number.”,b);
}
else if((c>a)&&(c>b)&&(c>d)&&(c>e))
{
printf(“%d is the Biggest Number.”,c);
}
else if((d>a)&&(d>b)&&(d>c)&&(d>e))
{
printf(“%d is the Biggest Number.”,d);
}
else
{
printf(“%d is the Biggest Number.”,e);
}
}

Output :

Method 2 :

#include<stdio.h>
#include<conio.h>
main()
{
int a,b,c,d,e,max;
printf(“Enter First the Number : “);
scanf(“%d”,&a);
printf(“Enter Second the Number : “);
scanf(“%d”,&b);
printf(“Enter Third the Number : “);
scanf(“%d”,&c);
printf(“Enter Fourth the Number : “);
scanf(“%d”,&d);
printf(“Enter Fifth the Number : “);
scanf(“%d”,&e);
if(a>b)
max=a;
else
max=b;
if(c>max)
max=c;
if(d>max)
max=d;
if(e>max)
max=e;
printf(“Biggest Number is : %d”,max);
}

Output :

Leave a Comment

Your email address will not be published.

2 thoughts on “C Program to find the Biggest of Five Numbers”

Shopping Basket
Verified by MonsterInsights