//Program
#include <stdio.h>
void main()
{
int a,b,c;
printf("Enter 3 different integer values : \n");
scanf("%d%d%d",&a,&b,&c);
if (a>b)
{
if(a>c)
{
printf("%d is largest",a);
}
else
{
printf("%d is largest",c);
}
}
else
{
if(b>c)
{
printf("%d is largest",b);
}
else
{
printf("%d is largest",c);
}
}
}
// using ternary operator find largest out of 3
#include <stdio.h>
void main()
{
int a,b,c,L;
printf("Enter 3 different integer values : \n");
scanf("%d%d%d",&a,&b,&c);
L = a>b?(a>c? a:c):(b>c? b:c);
printf("The largest value is %d",L);
}
No comments:
Post a Comment
Note: only a member of this blog may post a comment.