Header Ads Widget

C++ program to find the maximum among three numbers

 

 C++ program to find the maximum among three numbers 

Given three numbers , write a program to find the maximum among these numbers .

Sample input:

5  4 7

Sample output:

7 is maximum

 C++ program to find the maximum among three numbers 

The objective of the code is to find the maximum among three numbers given by user .

Code(C++):-

#include <bits/stdc++.h>
using namespace std;
int main()
{
  int a,b,c;
  cin>>a>>b>>c;
  if(a>b)
  {
    if(a>c)
   cout<<a<<" is maximum"<<endl;
    else
     cout<<c<<" is maximum"<<endl;
  }
  else
  {
    if(b>c)
   cout<<b<<" is maximum"<<endl;
    else
     cout<<c<<" is maximum"<<endl;
  }

}

Output:-

5
4
7
7 is maximum

Recommended Post :-

HCL Coding Questions:-

Capgemini Coding Questions:-

Companies interview:-

Full C course:-    

Key points:-

Cracking the coding interview:-

 Array and string:-

Tree and graph:-

Hackerearth Problems:-

Hackerrank Problems:-

Data structure:-

 MCQs:-