Home > Electronics Tutorials > C Language Tutorial > Statements - if

C Language Programming Library Reference Guide

Statements - if

The if statement evaluates an expression. If that expression is true, then a statement is executed. If an else clause is given and if the expression is false, then the else's statement is executed.

Syntax:
 

if( expression ) statement1;

or

if( expression ) statement1;
else statement2 ;
 
Examples:
 
if(loop<3) counter++;

if(x==y)
  x++;
else
  y++;

if(z>x)
 {
  z=5;
  x=3;
 }
else
 {
  z=3;
  x=5;
 }
Note: To report broken links or to submit your projects, tutorials please email to Webmaster

Discover

     more......