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

using namespace std;
int main()
  int x,y,z,max;

  cout<<"Enter The Three Numbers \n";

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



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

Previous Post
Next Post

post written by:

Hi, I’m Ghanendra Yadav, SEO Expert, Professional Blogger, Programmer, and UI Developer. Get a Solution of More Than 500+ Programming Problems, and Practice All Programs in C, C++, and Java Languages. Get a Competitive Website Solution also Ie. Hackerrank Solutions and Geeksforgeeks Solutions. If You Are Interested to Learn a C Programming Language and You Don't Have Experience in Any Programming, You Should Start with a C Programming Language, Read: List of Format Specifiers in C.
Follow Me