PASS AND NO RETURN
In Pass and no return, value(s) are passed from the calling function to the called function but no value is returned back from the called function to the calling function.
Question:1
Write a function C language to calculate and print square of a number?
Sol:
#include <stdio.h> //function definition void square(int n) { int s; s=n*n; printf("square = %d",s); } int main() { int a; printf("Enter any no "); scanf("%d",&a); square(a); return 0; }
Question:2
Write a function C language to take input for 2 nos calculate and print their sum?
Sol:
#include <stdio.h> //function definition void sum(int n1,int n2) { int s; s=n1+n2; printf("sum = %d",s); } int main() { int a,b; printf("Enter 2 nos "); scanf("%d %d",&a,&b); sum(a,b); return 0; }