This is the Selection Structure that performs one out of two or more Statements depending upon the Condition. Mean here according to the Condition (a>b) a is Greater then it will Print the first Statement and if b is Greater then it will Print the second Statement.
#include<iostream.h>
#include<conio.h>
void main()
{
int a,b;
cout<<"enter the values of a and b";
cin>>a>>b;
if(a>b)
{
cout<<"\n Greater no is : "<<a;
}
else
{
cout<<"\n greater number is : "<< b;
}
getch();
}
OUTPUT WILL BE:
#include<iostream.h>
#include<conio.h>
void main()
{
int a,b;
cout<<"enter the values of a and b";
cin>>a>>b;
if(a>b)
{
cout<<"\n Greater no is : "<<a;
}
else
{
cout<<"\n greater number is : "<< b;
}
getch();
}
OUTPUT WILL BE:
C++ program to Find Largest Number among three numbers
ReplyDeleteThanks for this code, it's very simple and easy.
Thanks Hitesh
Delete