Sunday, March 14, 2010
Selection statement in C
C support 2 selection statement
If and Switch
General form of IF is
if ( expression ) statement;
else statement.
Nested IF
if (i)
{
if (j) does something( );
if(k) doessomething( );
else doessomething( );
}
else doessomething( );
? this operator can replace the if-else statement into the general form
? is called ternary operator
General form is
Exp1 ? Exp2 : Exp3
Exp1 is evaluvated if it is true then print Exp2 else print Exp3
Example
X=10;
Y=X>9 ? 100 : 200;
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment