Current Set : Set 9
Set 1 Set 2 Set 3 Set 4 Set 5 Set 6 Set 7 Set 8 Set 9 Set 10
No pass and return
In No Pass and Return, no value is passed from the calling function to the called function but a value is returned back from the called function to the calling function.
Question:1
Write a function in C language to calculate and print square of a number?
Sol:
#include <stdio.h>
//function definition
int square()
{
int a;
printf("Enter any no ");
scanf("%d",&a);
return(a*a);
}
int main()
{
int s;
s=square();
printf("square = %d\n",s);
return 0;
}
Question: 2
Write a function in C language to take input for 3 numbers calculate and print their product?
Sol:
#include <stdio.h>
//function definition
int prod()
{
int a,b,c;
printf("Enter 3 nos ");
scanf("%d %d %d",&a,&b,&c);
return(a*b*c);
}
int main()
{
int s;
s=prod();
printf("product = %d\n",s);
return 0;
}




