Muhammad Ali Nayeem Student of Knowledge
Muhammad Ali Nayeem Student of Knowledge
Student of Knowledge
http://teacher.buet.ac.bd/ali_nayeem/
We have already learned 2 types of statements
Declaration statement
Assignment statements
Default order ?
Often we need to alter/change order
When?
if
General form if(expression)
statement;
A new keyword
expression:
any valid C expression
know as target
statementN;
}
else
{
statement1;
statement2;
…
statementN;
}
If expression is true all the statements with if will be executed
If expression is false all the statements with else will be executed
Connect together true/false results
‘&&’ logical AND binary
‘||’ logical OR binary
‘!’ logical NOT unary
It is perfectly all right if we write an entire if-else construct within
either the body of the if statement
or the body of an else statement.