Find smallest in four number by using Ternery operator
//By Brijesh
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c,d,ans;
clrscr();
printf("enter the 4 value \n");
scanf("%d%d%d%d",&a,&b,&c,&d);
ans=(a>b&&a>c&&a>d)?a:(b>a&&b>c&&b>d)?b:(c>a&&c>b&&c>d)?c:d;
printf("greatest=\t%d",ans);
getch();
}
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c,d,ans;
clrscr();
printf("enter the 4 value \n");
scanf("%d%d%d%d",&a,&b,&c,&d);
ans=(a>b&&a>c&&a>d)?a:(b>a&&b>c&&b>d)?b:(c>a&&c>b&&c>d)?c:d;
printf("greatest=\t%d",ans);
getch();
}
No comments
Post a Comment