Write a program to show the use of subroutines
Hints: We have used only printf function that has been provided for us by the C system. The program below uses a user-defined function. A function defined by the user is equivalent to subroutine in FORTRAN or Subprogram in Basic.
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);
}
<< Go to Index Page >>
main()
উত্তরমুছুন{
int a,b,c;
printf("Enter the value of a:\n");
scanf("%d",&a);
printf("Enter the value of b:\n");
scanf("%d",&b);
c=rose(a,b);
printf("Multiplication of %d and %d is:\n");
printf("%d",c);
}
rose(x,y,p)
int p,x,y;
{
p =x*y;
return (p);
}
#include
উত্তরমুছুনvoid maximum (int x,int y,int z);
main()
{
int i,j,k;
scanf("%d%d%d",&i,&j,&k);
maximum(i,j,k);
}
void maximum(int x,int y,int z)
{
int sum=0;
sum=x+y+z;
printf("The sum is %d",sum);
}
main()
উত্তরমুছুন{
int a,b,c;
printf("Enter the value of a:\n");
scanf("%d",&a);
printf("Enter the value of b:\n");
scanf("%d",&b);
c=rose(a,b);
printf("Multiplication of %d and %d is:\n");
printf("%d",c);
}
rose(x,y,p)
int p,x,y;
{
p =x*y;
return (p);
}