/* */ Click to Join Live Class with Shankar sir Call 9798158723

Categories of function in C ?


  1. function with no parameters and no return values
  2. function with no parameters and return values
  3. function with parameters and no return values
  4. functions with parameters and return values


function with no parameters and no return values

There is no data transfer between the calling function and called function. So, calling function cannot send values and hence, called function cannot receieve the data. This is also called "void functions with no parameters".


Q.) W.A.P for function with no parameters and no return values.
 #include<stdio.h>
 #include<conio.h>
 void sum();
 void main()
 {                        
 sum();                    	
 getch();
 }
 void sum()
 {
 int a ,b,s;
 printf(“enter two no\n”);
 scanf(“%d%d”,&a,&b);
 s=a+b;
 printf(“%d”,s); 
 }
Output
enter two numbers: 5 6
11

function with parameters and return values

there is data transfer between the calling function and called function. When parameters are passed, the called function can receieve values from the calling function. When the function returns a value, the calling function can receive a value from the called function.


Q.) W.A.P for function with parameters and return values.
 #include<stdio.h>
 #include<conio.h>
 int sum(int ,int );
 void main()
 {
 int a, b, c;
 printf(“enter Two no\n”);
 scanf(“%d%d”,&a,&b);
 c=sum(a,b);
 printf(“%d”,c);
 getch();
 }
 int sum(int  x, int  y)
 {
 int s; 
 s=x+y;
 return s;
 }
Output
enter two numbers: 5 6
11

function with parameters and no return values

There is data transfer from the calling function to the called function using parameters. But, there is no data transfer from called function to the calling function.


Q.) W.A.P for function with parameters and no return values.
  #include<stdio.h>
  #include<conio.h>
  void sum(int ,int );
  void main()
 {
 int a ,b;
 printf(“enter Two no\n”);
 scanf(“%d%d”,&a,&b);
 sum(a,b);
 getch();
 }
 void sum(int x, int y)
 {
 int s;
 s=x+y; 
 printf(“%d”,s);
 }
Output
enter two numbers: 5 6
11