Write a program using user-defined funtion.

The program uses a user-defined function. A function defined by the user is equivalent to a subroutine in FORTRAN or subprogram in BASIC.

#include <stdio.h>
main()
{
int a,b,c;
a = 5;
b = 10;
c = mul(a,b);
printf(" Multiplication of %d and %d is %d.", a,b,c);
}
mul(x,y)
int p,x,y;
{
p = x*y;
return(p);
}

The program will print the following output:

Multiplication of 5 and 10 is 50.

No comments:

Post a Comment