Friday, May 3, 2019

If Else Statement in C

In general it can be used to execute one block of statement among two blocks, in C language ifand else are the keyword in C.
if else statement in c

Syntax

if(condition)
{
........
statements
........
}
else
{
........
statements
........
}
In the above syntax whenever condition is true all the if block statement are executed remaining statement of the program neglecting. If the condition is false then else block statement will executed and neglecting if block statements.

Example

#include<stdio.h>
#include<conio.h>

void main()
{
int time=10;
clrscr();
if(time>12)
{
printf("Good morning");
}
else
{
printf("Good after noon");
}
getch();
}

Output

Good morning

No comments:

Post a Comment

Why learning C Programming is a must?

C is a procedural programming language. It was initially developed by Dennis Ritchie between 1969 and 1973. It was mainly developed as...