3.2.The if – else statement #

The if – else statement used for two conditions, if statement will process when the condition true and it’s will choose the else statement automatically when the if condition false.
Syntax 1:

if(condition)
	statement 1;
else
	statement 2;

Syntax 2:

if(condition)
{
	statement 1;
	...		
	statement n;
}
else
{
	statement 2;
	...		
	statement n;
}

Example 1:

#include<iostream.h>
#include<conio.h>
void main()
{
	float score;
	cout<<"Enter Score: ";            cin>>score;
	if(score>=50)
		cout<<"Passed";
	else
		cout<<"Failed";
	getch();
}
Suggest Edit