Q:

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

0

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

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

#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:

Enter The Three Numbers 

100

200

300

The Greatest Number In Given Numbers 100 200  300 is 300

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

C++ Program To Check Year Is Leap Year Or Not... >>
<< C++ Program To Convert A Lower Case To Upper Case ...