Pages

Wednesday, November 11, 2015

C++ Program to Compare The Greatest Of Three Integers

C++ program to compare which is the greatest among three numbers. An IF statement is used to set the condition to know which is less or greater than which.

#include<iostream.h>
#include<math.h>
#include<conio.h>
void main()
{
int a,b,c;
clrscr();
cout<<"enter the first value";
cin>>a;
cout<<"enter the second value";
cin>>b;
cout<<"enter the third value";
cin>>c;
if (a>b&&b>c)
cout<<"The greatest is: "<<a;
else
if(a<b&&b>c)
cout<<"The greatest is: "<<b;
else
if(a<b&&b<c)
cout<<"The greatest is: "<<c;
else
if(a==b&&b==c)
cout<<"Non is greater!!";
}