Thursday, 23 July 2015

C Program - To find the maximum of three values without using Logical Operators

C program to find the maximum of 3 values 




#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)
{
if(a>c)
{
printf("\nA is greater than B and C");
}
else if(a==c)
{
printf("\nA and C are equal and they have higher value than B");
}
else
{
printf("\nC is greater than A and B");
}
}
else if(a==b)
{
if(a>c)
{
printf("\nA and B are eqaul and they have higher value than C");
}
else if(a==c)
{
printf("\nA, B and C all are equal");
}
else
{
printf("\nC is greater than A and B");
}
}
else if(b>c)
{
printf("\nB is greater than A and C");
}
else if(b==c)
{
printf("\nB and C are equal and they have higher value than A");
}
else
{
printf("\nC is greater than A and B");
}
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