
Syntax:
if (condition)
{
Statements;
.
.
}
else
{
Statements;
.
.
}
Eg:
if (a>b)
cout<<” a is big “;
else
cout<<” b is big “;
/*——————————————————————–*/
#include<iostream.h>
#include<conio.h>
void main()
int a,b ;
cout<<”Enter values for a and b : “;
cin>>a>>b;
if (a>b)
cout<<endl<<” a is big “;
else
cout<<endl<<” b is big “;
getch();
}
/*—————————————————————————-*/
Output:
Enter values for a and b : 100 20
a is big
See also: Nested if statements in C++
Not Satisfied ? Just search & get the result
Related posts:
