Skip to content

Control Statements

These statements are used to change normal flow of program execution.

Normal Flow of Program or sequential execution
each line in the code exactly one times, Top to bottom


Three types of Control Statements:
1. Selections/Decisions/Branching/Conditional
2. Loops/Iterations/Repetitions
3. Jumps

Selections in C Language
1. simple if
2. multiple if
3. if…else
4. nested if
5. else…if
6. switch…case

Simple if
it is used to execute a group of statements or block when a condition is returned true.


Write Algorithm and draw Flow chart to determine the value of a variable is natural number.


#include<stdio.h>

//Example of simple if
void main()
{
int x=12;

if(x>0)
{
printf(“%d is natural number”,x);
}
printf(“\nRest of the program”);
}

Ex1)
Write C program to accept age from the user and display message “eligible for voting” when the age entered is greater than 18.
Hint:
age>18

Ex2)
Write C program to determine whether the user entered number is even or odd
Hint:
x%2==0
x%2!=0

Ex3)
Write C code to determine whether the user entered number is greater than, less than or equal to zero
Hint:
a>0
a<0
a==0

Ex4)
Write C program to accept any number out of 2,4,6,8 from the user and display the input number in words.

Example output:
Enter any number from 2,4,6,8: 4
FOUR