codescracker


c

C Program to Find Largest of Three Numbers



« Previous Program Next Program »


Find Largest of Three Numbers in C

To find the largest number of/among the three numbers in C programming, you have to ask to the user to enter the three number, now start checking which one is the largest number. After finding the largest, display that number as the largest number of the three number

C Programming Code to Find Largest of Three Numbers

Following C program ask to the user to enter the three number to check which one is the largest or biggest of the three number, then display the result on the screen :

/* C Program - Find Largest of Three Numbers */
		
#include<stdio.h>
#include<conio.h>
void main()
{
	clrscr();
	int a, b, c, big;
	printf("Enter three numbers : ");
	scanf("%d%d%d",&a,&b,&c);
	//let a is the biggest
	big=a;
	if(big<b)
	{
		if(b>c)
		{
			big=b;
		}
		else
		{
			big=c;
		}
	}
	else if(big<c)
	{
		if(c>b)
		{
			big=c;
		}
		else
		{
			big=b;
		}
	}
	else
	{
		big=a;
	}
	printf("Biggest number is %d",big);
	getch();
}

When the above c program is compile and executed, it will produce the following result. Above C Programming Example Output (for c):

c program find biggest of three numbers

Above C Programming Example Output (for b):

c program find largest of three numbers

Above C Programming Example Output (for a):

c program find greatest in three numbers

Same Program in Other Programming Language

You may also like same program in other programming languages:


« Previous Program Next Program »



Tools
Calculator

Quick Links
Signup - Login - Give Online Test