Tuesday, 12 April 2016

Write a Program in c++ to find max no among two using function.

//wap in c++ to find max no among two using function.
 



Coding:-

#include<iostream.h>
#include<conio.h>

int max(int num1,int num2); //function Declaration
int main()
{
clrscr();



int a,b;
cout<<"enter first no:";
cin>>a;
cout<<"\n enter second no:";
cin>>b;
int ret;
ret=max(a,b);  //function call
cout<<"max value is:"<<ret;
getch();
return 0;
}
int max(int num1,int num2)
{
int result;
if(num1 > num2)
{
result=num1;
}
else
{
result = num2;
}
return result;
}



Output:- 





No comments:

Post a Comment