C control statements

C control statements

Control Statements

In c programming, statements are executed sequentially or step by step in the order in which they are write in the program. Sometimes i want executes some parts of program on the basis of conditions. Also some times many situations arise where we want to use any statement or some statements several times.in all these conditions the control statements are use

Selection Statements Iterative Statements Jump Statements
if-else while statements break
Switch do-while statement continue
for statement goto

Compound Statement or Block

A compound statement is a block or group of statements enclosed within pair of curly braces {}. So the statements inside a block are execute sequentially

Here is general form of block

{
statement1;
statement2;
statement3;
……….
……….
……….
}

if-else

It is bi-directional selection control statement which used to take one action from two possible actions.so here is syntax of an if else statement

if(Expression) {
statement1;
statement2;
………
}
else
{
statement3;
statement4;
……….
}

In this expression inside the parenthesis is evaluated if value inside the parenthesis is true (non-zero value), then statements of inside if block executed and if expression is false(zero) then statements of else block executed.

#include<stdio.h>
int main()
{
int a=10,b=6;
if(a>b)
{
printf("Bigger number = %d",a);
}
else
{
printf("Bigger number = %d",b);
}
return 0;
}