Lecture on if-else
Content covered: 

if-else Statement :
Consider a situation,
If marks of a student are less than 40 then he has failed in the exam otherwise he passed.

We can model this situation in C programming language using if-else statements.

if (<conditional expression>) {
 // if block 
else {
// else block

Note-  If condition given within if parenthese evaluates as nonzero(True) then if block executes otherwise if the value of conditional expression is zero (False), then else block will execute.
So for our model,

if (marks < 40){
printf ("fail");
else {
printf ("pass");


More Less