If Else in C++

Advertisements

Prev Tutorial Next Tutorial


If Else Statement in C++

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

if else statemnt 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 by neglecting else block statement. If the condition is false else block statement remaining statement of the program are executed by neglecting if block statements.

Example of If Else Statement in C++

#include<iostream.h>
#include<conio.h>

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

Output

Good morning

Output

Good morning

Prev Tutorial Next Tutorial

Google Advertisment

Buy This Ad Space @$20 per Month, Ad Size 600X200 Contact on: hitesh.xc@gmail.com or 9999595223

Magenet is best Adsense Alternative here we earn $2 for single link, Here we get links ads. Magenet

For Projects 9999595223

Google Advertisements


Buy Websites 9999595223

Buy College Projects with Documentation Contact on whatsapp 9999595223. Contact on: hitesh.xc@gmail.com or 9999595223 Try this Keyword C++ Programs

Advertisements