Function Catagories

There are four main categories of the functions these are as follows:

1. Function with no arguments and no return values.
2. Function with no arguments and a return value.
3. Function with arguments and no return values.
4. Function with arguments and return values.

Function with no arguments and no return values:

syntax:
void funct (void);
main ( )
{
funct ( );
}
void funct ( void );
{
}

NOTE: There is no communication between calling and called function. Functions are
executed independently, they read data & print result in same block

Example:
void link (void) ;
int main ()
{
link ();
}
void link ( void );
{
printf (“ link the file “)
}

Function with no arguments and a return value: This type of functions has no arguments but
a return value

example:
int msg (void) ;
int main ( )
{
int s = msg ( );
printf( “summation = %d” , s);
}
int msg ( void )
{
int a, b, sum ;
sum = a+b ;
return (sum) ;
}

NOTE: Here called function is independent, it read the value from the keyboard, initialize and
return a value .Both calling and called function are partly communicated with each other.

Function with arguments and no return values:
Here functions have arguments so, calling function send data to called function but called
function does no return value. such functions are partly dependent on calling function and result
obtained is utilized by called function .

Example:
void msg ( int , int );
int main ( )
{
int a,b;
a= 2; b=3;
msg( a, b);
}
void msg ( int a , int b)
{
int s ;
sum = a+b;
printf (“sum = %d” , s ) ;
}

Function with arguments and return value:
Here calling function of arguments that passed to the called function and called function
return value to calling function.

example:
int msg ( int , int ) ;
int main ( )
{
int a, b;
a= 2; b=3;
int s = msg (a, b);
printf (“sum = %d” , s ) ;
}
int msg( int a , int b)
{
int sum ;
sum =a+b ;
return (sum);
}

Try Now – Programming In C MCQs