Ticker

6/recent/ticker-posts

C (Conditional operator in c)

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 >>







Post a Comment

0 Comments