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!!";
}



Do you like this post? Please link back to this article by copying one of the codes below.

URL Of Post:


HTML Link Code:

BB (forum) link code:

Comments