What is 'Ternary Operator' ?
Ternary operator is the operator in c – language which is mainy used instead of writting if-else if- else condition. This operator do same task as if-else do. The mainly advantage to use it is time saving while writting a huge code . If you write 7 to 8 line with the help of if – else condition , the same task can be implemented with in a single line or maximum 2 lines by using ‘Ternary Operator’ .
Some example using Terbary Operator:—
#include<stdio.h>
int main()
{
int a,b,Big;
printf("\tEnter a values of a : ");
scanf("%d",&a);
printf("\tEnter a values of b : ");
scanf("%d",&b);
Big= a>b? a : b ;
printf("\tBig=%d",Big);
return 100;
}
Output :-
I think confusion is over on ternary operator. You can also check how this code can be implemented by using if- else condition by clicking the link given below. Have a good day….
very good
it is so helpful
LikeLike