Program to find greatest number among three numbers using Ternary Operator in c language.

 ● Using ternary operator->

#include<stdio.h>
#include<conio.h>
void main()
{
 int ans,a,b,c;
 clrscr();
 printf("enter three numbers=");
 scanf("%d%d%d",&a,&b,&c);
 ans=a>b?(a>c?a:c):(b>c?b:c);
 printf("greatest number is =%d",ans);
 getch();
}

■》 Output->

enter three numbers=
5
8
2
greatest number is =8

Comments

Popular posts from this blog

Introduction of java Programming language.

Stack data structure.