Pages

Thursday, July 30, 2020

CONDITIONAL OPERATOR IN C



CONDITIONAL OPERATOR (?:)
The conditional operator is used to implement at-most two conditions therefore its work as an alternative of If-else statement.

CONDITIONAL OPERATOR SYNTAX
big = a>b ? a:b;

Explanation: In the above example 'big' is a variable that assign the value that produce by conditional operator. 




CONDITIONAL OPERATOR EXAMPLE IN C
#include<stdio.h>
#include<conio.h>
void main()
{
Clrscr():
int a=5, b=13, big;
big = a>b ? a:b;
printf(“Biggest value is:%d”,big);
getch();
}

Note: In the above statement, if condition would be true then “big” assign value of first variable and if false then “big” assign value of second variable.

                                           PRIMARY DATA  TYPES IN C >>

No comments:

Post a Comment