How to find greatest of 3 numbers?
CODE
How to find greatest of 3 numbers?
//Write a program to find
greatest of 3 numbers…..
#include<iostream>
using namespace
std;
class gr
{
int a,b,c,max;
public:
void input()
{
cout<<"\n enter
a,b,c:";
cin>>a>>b>>c;
}
void pro()
{
if(a>b)
{
if(a>c)
max=a;
else
max=c;
}
else
if(b>c)
max=b;
else
max=c;
}
void out()
{
cout<<"\n greatest
number="<<max;
}
};
int main()
{
gr obj;
obj.input();
obj.pro();
obj.out();
}
Output:
enter a,b,c:45
78
26
greatest number=78
How to find greatest of 3 numbers?
Reviewed by Unknown
on
January 01, 2019
Rating:
No comments:
If you have any doubt or query ,comment below: