Conditional Statements:
Conditional statements in C++ helps to take decision between statements. They are of three types:
if statements: When the programing depends on only single decision. Syntax: if (conditional statement) { //body}
if-else statements
if-else if-else statements
/* Program to find the largest of two entered numbers */
#include <iostream>
using namespace std;
int main()
{
int num1, num2;
cout<<"Enter first number:\t";
cin>>num1;
cout<<"Enter second number:\t";
cin>>num2;
if(num1>num2)
{
cout<<"First number "<<num1<<" is the largest";
}
else
{
cout<<"Second number "<<num2<<" is the largest";
}
return 0;
}