C++ language

Largest Number
Previous Home Next

Program For Finding Largest Number in C++

#include<stdio.h>
class num
{
int a,b,c;
public :
void input(void);
void largest(void);
void smallest(void);
};
void num::inputdata(void)
{
cout<<"Input value of a ";
cin>>a;
cout<<"Input value of b";
cin>>b;
cout<<"input value of c";
cin>>c;
}
void number :: largest(void)
{
if(a>b)
{
if(a>c)
cout<"\n largest value"<<<a;
else
cout<<"\n largest value"<<c;
}
else
{
if(b>c)
cout<<"\n largest value"<<b;
else
cout<<"\n largest value"<<c;
}
}
void num::smallest(void)
{
if(a<b)
{
if(a<c)
{
cout<<"\n smallest number"<<a;
else 
cout<<"\n smallest number"<<c;
}
else
{
if(b<c)
cout<<"\n smallest numeber"<<b;
else
cout<<"\n smallest number" <<c;
}
}
int main()
{
num n;
n.input();
n.largest();
n.smallest();
return 0;
}

Output:

input value of a=15
input value of b=34
input value of c=30
largest value is 34
smallest value is 15 
Previous Home Next