source file name: MaxFun.C
int max(int m, int n) // declaration and definition
{
int res;
if(m>n)
res=m;
else
res=n;
return res;
}
void main()
{
int a,b;
int result;
clrscr();
printf("enter 2 numbers: ");
scanf("%d%d",&a,&b);
result= max(a,b); // calling function
printf(" max value=%d ",result);
getch();
}
output:
1. enter 2 numbers:
500 100
max value= 500
2. enter 2 numbers:
225 160
max value= 225
0 Comments
Post a Comment