These are the four categries of a function.
i)A function with argument with return value.
A function which have some argument and return some value.
#include<stdio.h> int multiply(int x,int y); //prototype define int multiply(int x,int y) //called function { int x,y,z; z=x+y; return z; } int main() { int x,y,multi; printf("Enter the first value="); scanf("%d",&x); printf("Enter the second value="); scanf("%d",&y); multi=multiply(x,y);//calling function printf("%d",multi); return 0; }
ii) A function with argument without return value.
A function which have some argument and without return any value.
Example#include<stdio.h> void multiply(int x,int y); //prototype define void multiply(int x,int y) //called function { int x,y,z; z=x*y; printf("%d",z); } int main() { int x,y; printf("Enter the first value="); scanf("%d",&x); printf("Enter the second value="); scanf("%d",&y); multiply(x,y);//calling function return 0; }
iii) A function without argument with return value.
A function which have no argument pass and return some value.
Example#include<stdio.h> int multiply(void); //prototype define int multiply(void) //called function { int x=10,y=20,z; z=x*y; return z; } int main() { int multi=0; multi=multiply();//calling function printf("%d",multi); return 0; }
iv) A function without argument without return value.
A function which have no any argument pass and without return any value.
Example#include<stdio.h> void multiply(void); //prototype define void multiply(void) //called function { int x=10,y=15,z; z=x*y; printf("%d",z); } int main() { multiply();//calling function return 0; }