max of two numbers

Write a program to find maximum of two numbers.

Procedure:

  • Enter two numbers n1,n2
  • If n1>n2, print n1
  • else print n2
#include<iostream>
using namespace std;
int main(){
	int n1,n2;
	cout<<"Enter two numbers : "<<endl;
	cout<<"n1 : ";
	cin>>n1;
	cout<<"n2 : ";
	cin>>n2;
	if(n1>n2){
		cout<<n1<<" is greater";
	}
	else{
		cout<<n2<<" is greater";
	}
	return 0;
}
maximum of two numbers
maximum of two numbers

One Reply to “max of two numbers”

Leave a Reply

Your email address will not be published. Required fields are marked *