Thursday 23 July 2015

C Program - To find maximum of 3 values using logical operators

C program to find the maximum of 3 values using operators 




#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c;
clrscr();
printf("\nEnter the value for a :- ");
scanf("%d",&a);
printf("\nEnter the value for b :- ");
scanf("%d",&b);
printf("\nEnter the value for c :- ");
scanf("%d",&c);
if( a>b  &&  a>c)
{
printf("\nA is greater than B and C");
}
else if( b>a  &&  b>c)
{
printf("\nB is greater than A and C");
}
else if(c>a  &&  c>b)
{
printf("\nC is greater than A and B");
}
else if( a==b  &&  b==c)
{
printf("\nA, B and C all are equal");
}
getch();
}

Output :- 


Enter the value for a :- 10
Enter the value for b :-  5
Enter the value for c :- 6

A is greater than B and C


Back to 'C Language Programs'


No comments:

Post a Comment