Site icon T4Tutorials.com

Write a C++ program to find the maximum between two numbers. Using the switch statement

Write a C++ program to find the maximum between two numbers. Using the switch statement.

Flowchart of the program to find the maximum between two numbers with the help of  switch statement

C++ source code to show the maximum number between two numbers by using the switch statement

#include<iostream>
using namespace std;
int main()
{
	int n1,n2;
	cout<<"enter n1"<<endl;
	cin>>n1;
	cout<<"enter n2"<<endl;
	cin>>n2;
	switch(n1>n2)
	{
		case 0:
			cout<<n1<<"is not greater"<<endl;
			break;
		case 1:
			cout<<n1<<"is greater"<<endl;
			break;
		default:
			cout<<"invalid"<<endl;
	}
}

SFT (Shamil’s Flow Table )

Are you interested to Read about SFT(Shamil’s Flow Table)?

Exit mobile version