Conditional Operator
It is also a decision-making statement. It is an alternative to if-else.it is known as ternary operator as it has three operands.
Syntax:
(condition)? true-case statement: false case statement;
Flow chart
Syntax:
(condition)? true-case statement: false case statement;
Flow chart
Example:
#include<stdio.h>
#include<conio.h>
void main ()
{
int x,y;
clrscr();
printf("Enter two numbers:");
scanf("%d %d",&x,&y);
x>y ? printf("%d is larger",x): printf ("%d is larger",y);
getch();
}
#include<stdio.h>
#include<conio.h>
void main ()
{
int x,y;
clrscr();
printf("Enter two numbers:");
scanf("%d %d",&x,&y);
x>y ? printf("%d is larger",x): printf ("%d is larger",y);
getch();
}