Conditional Statement

Conditional Statement

Sometimes, we need to perform different actions based on different conditions. It can be perform with the help of Relational operator or conditional statement.

Conditional Operator

>greater than
Example:- a=4 and b= 2; a>b
a is greater than b
<less than
Example:- a=2 and b=4; a
a is less than b.
>=greater than or equal to
<=less than or equal to
==equals to
Example: a=2 and b=2;a==b
a is equals to b
!=is not equals to
Example: a=2 and b=4; a!=b
a is not equals to b

Relational Operator

&&ANDif both condition true than statement will be execute.
||ORany one condition true than statement will be execute

Conditional Or Branch Statements

The if Statement(One way selection/decision)

An if statement is a single selection or decision used when we have only one alternative .

        statement 1
        statement 2
         statement n
the statements are executed if the condition is true.

W.A.P to print the largest no:-

void main()
   int a,b,big;
   printf("Enter two numbers\n");
   printf("largest number=%d",big);


Enter two numbers
3  4
largest number=4