R4R
Right Place For Right Person TM
 
R4R C C ExamplesGreatest number of any three given numbers
previous

Home

Next

Learn C with example

Greatest number of any three given numbers

In this example we are going to find the greatest number in any three 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 Of Example

Enter the three numbers 1 2 3
3 is greatest number
previous

Home

Next

New Updates

R4R
R4R
R4R
R4R
R4R
R4R
R4R
R4R