If condition in c programming language

C Program executes sequentially i.e. line after line but we can change this pattern by entering some condition in it. So, if we put some condition then the flow of execution changes i.e. conditions are checked and then executed accordingly. If the condition found true the statements in conditional area will be executed otherwise it will leave the conditional area and will execute the code next to if skeleton.

The C programming language provides a general decision making construct known as ‘if’ statement. The syntax of ‘if’ statement is shown below.

if(expression){ Program statements;}

The expression is evaluated, if it is true and subsequently program statements will get executed, otherwise the statement is skipped and control will move outside the if skeleton.

#include <stdio.h>
int main()
{
    int age;
    printf("Enter your age\n");
    scanf("%d", &age);
    printf("You have entered %d as your age\n", age);
    if (age>=18) 
    {
        printf("You can vote!");
    }
return 0;
}

Flowchart of if statement

If condition in c programming language, www.programmingtutorial.in
If condition