Maximum using function

Write a C++ program to find maximum of two numbers using a function. The function should input two values and return the maximum of the two.

#include<iostream>
using namespace std;
int max(int a,int b){
	if(a>b)return a;
	else return b;
}
int main(){
	int a,b,c;
	cout<<"Enter two numbers "<<endl;
	cout<<"a : ";
	cin>>a;
	cout<<"b : ";
	cin>>b;
	c = max(a,b);
	cout<<"Maximum value is "<<c<<endl;
	return 0;
}
output of the above program. maximum of the two value
output of the above program. maximum of the two value

One Reply to “Maximum using function”

Leave a Reply

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