Simple if statement in C language

Simple if statement in C language

Simple if statement in C language is a very powerful decision making statement and it is used to control the flow of execution of statements.

There are four types of if statement:

Simple if statement in C language

 In simple if statement, there is only one Condition and depending upon the Condition, a particular set of statements will be executed. The syntax of simple if statement is:

if(Test)
{
Block;
}
Test is the condition made using relational or logical operators.

If condition is true, Block  of statements gets executed. otherwise Block will not execute.

Block  is a set of valid C language statements .

Program to demonstrate simple if statement in C Language.
#include<stdio.h>
int main()
{
int a=10;
if(a<0)
  printf("number is -ve");
printf("\nBye");
return 0;
}
Output
Bye

In the above program, a is 10. 

Condition a<0 is false so only printf(“\nBye”) would be executed.

Spread the love
Lesson tags: if statement in c, simple if statement in c, types of if statement in c
Back to: C Programming Language
Spread the love