C++ Program To Find Greatest Between Three Numbers

Program To Find Greatest Between Three Numbers

C++ Program To Find Greatest Between Three Numbers.

#include<iostream.h>
#include<conio.h>
void main()
{
 clrscr();
 int a,b,c;
 cout<<"Enter Value of a:- "<<endl;
 cin>>a;
 cout<<"Enter Value of b:- "<<endl;
 cin>>b;
 cout<<"Enter Value of c:- "<<endl;
 cin>>c;
 if(a>b)
 {
  if(a>c)
   {
   cout<<"a is Greater";
   }
   else
   {
   cout<<"c is Greater";
   }
 }
 else
 {
 if(b>c)
   {
    cout<<"b is greater";
   }
   else
   {
    cout<<"c is Greater";
   }
 }
 getch();
}

OUTPUT:-

Find Greatest Between Three Numbers


Using single inheritance

#include<iostream.h>
#include<conio.h>
class scan
{
 protected:
 int a,b,c;
 public:
 void get()
 {
  cout<<"Enter value of a:- ";
  cin>>a;
  cout<<"Enter value of b:- ";
  cin>>b;
  cout<<"Enter value of c:- ";
  cin>>c;
 }
};
class great:public scan
{
 public:
 void great_val()
 {
 if(a>b)
 {
  if(a>c)
   {
   cout<<"a is Greater";
   }
   else
   {
   cout<<"c is Greater";
   }
 }
 else
 {
 if(b>c)
   {
    cout<<"b is greater";
   }
   else
   {
    cout<<"c is Greater";
   }
 }
 }
};
void main()
{
 clrscr();
 great g1;
 g1.get();
 g1.great_val();
 getch();
}

OUTPUT

Find Greatest Between Three Numbers


Comment below if you are facing any problem


Also read

C++ Program to count no. of digits in the input


Leave a Reply

Your email address will not be published. Required fields are marked *