10/31/2015

C++ Program To  Find Max Number Among Given Three Number

Problem :- Write A Program To  Find Max Number Among Given Three Number

Logic :- This Is a different logic to find max number among three number .

Step 1:- we use forth variable as 'max' and store first element in max then compare max to next to element 

Step 2 :- if second number is greater than max then store second number in max if it is less then compare with third element

Step 3 :- If third number is greater then store third element in max if condition fails then first number is greater

Solution :- 

#include<iostream>
using namespace std;
int main()
{
  int x,y,z,max;

  cout<<"Enter The Three Numbers \n";
  cin>>x>>y>>z;

  max=x;
if (y>max)
  {
  max=y;
}
if(z>max)
  {
  max=z;
}
cout<<"\nThe Greatest Number In Given Numbers "<<x<<" "<<y<<"  "<<z<<" is "<<max;

}

Output:- 

C++ Program To  Find Max Number Among Given Three Number

Ghanendra Yadav

Ghanendra Yadav

Hello, I Am Ghanendra Yadav Owner of This Blog, I am professional Blogger and Programmer. I Love Programming, Logo Making, And Banner Designing. My Highest Qualification is MCA From NIT Warangal. You Can Find Me On Social Media Through Below Link And If You Have Any Query Related To Programming And Other Subject Comment Below or You Can Mail Me I Will Try To Answer Within 24 Hours Email:- yghanendra@student.nitw.ac.in

Find me on Social Media

Facebook | Twitter | Google+ | RSS Feed

No comments:

Post a Comment