C Programming language

adplus-dvertising
C Program example: Find greatest number of any three given numbers
Previous Home Next
Greatest number of any three given numbers

In this we are declaring three variables a,b,c. We insert values from keyboard into these values. Then check the conditions .Here we are using && operator two check two condition at a time. This operator is also called short circuit operator. This operator returns true if both value is true else it returns false.

/* Greatest number of any three given numbers */

#include<stdio.h>
#include<stdio.h>
void main()
{
	int a,b,c;
	clrscr();
	printf("Enter the three numbers\t");
	scanf("%d%d%d",&a,&b,&c);
	if(a>b && a>c)
		printf("%d is greatest number",a);
	else if(b>c && b>a)
		printf("%d is greatest number",b);
	else
		printf("%d is greatest number",c);
	getch();
}
Output :

Enter the three numbers 1  2  3

3 is greatest number

Previous Home Next