OUTPUT (after running):
2
4
4
8
10
1
Application:
The sizeof operator is used, in general, to find out the length of secondary data types
like arrays, structures, classes, and so on, when their sizes are unknown to the programmer.
Ternary Operator
C also provides a ternary operator that takes three operands (hence its name). Its syntax is:
expression1 ? expression2 : expression3;
That is, if expression1 is true, then expression2 is evaluated; else, expression3 is evaluated.
The
ternary operators are also called conditional operators.
For example,
#include
void main( )
{
int u, v, w;
u = 20;
v= 30;
w = (u > v ? u : v);
printf(“\n Greatest out of the two is %d”, w);
}
Do'stlaringiz bilan baham: |