Monday, 2 March 2015

C++Program To Find Greatest Of Three Number

Problem :- Write A Program To Find Greatest Of Three Number

Logic :- Logic Is very Simple Follow the below step's

Step 1 :-

If first number is greater then remaining two then print first one in greater

Step 2 :-

If Second number is greater then remaining two then print Second one in greater

Step 3 :-

If Third number is greater then remaining two then print Third one in greater

Step 4 :-

If step 1 to 3 are not true then all three number's are equal. 

Solution :-

#include<iostream>
using namespace std;
int main()
{
int a,b,c;
 
cout<<"Enter Three Number :\n\n";
  cin>>a>>b>>c;
 
if(a>b&&a>c)
  {
  cout<<"First Number is Greatest \n";
  }
  else if(b>a&&b>c)
  {
  cout<<"Second Number is Greatest \n";
  }
  else if(c>a&&c>b)
  {
  cout<<"Third Number is Greatest \n";
  }
  else
  cout<<"All Number Are Equal \n";
 return 0;


}

Output:-

Condition 1:-

C++Program To Find Greatest Of Three Number


Condition 2:-

C++Program To Find Greatest Of Three Number


No comments:
Write comments

Recommended Posts × +