Header Ads Widget

C++ Program to find the maximum between two numbers by using the switch statement

 

 C++ Program to find the maximum between two numbers by using the switch statement

Given two numbers , write a program to find the maximum between both by using switch statement . 

Sample input

17 10 

Sample output

17 number is greater

 C++  Program to find the maximum between two numbers by using the switch statement

The objective of the code is find the maximum between two numbers by using switch case .

Code(C++):-

#include <iostream>
using namespace std;
int main() {
       int a,b;
cout<<"Enter the numbers ";
cin>>a>>b;
int ch=a>b;
switch(ch)
{
case 1:cout<<a<<" number is greater ";
break;
case 0:cout<<b<<" number is greater";
break;
}
}


Output:-

Enter the numbers
17 10
17 number is greater


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

Post a Comment

0 Comments