Blogger templates

Pages

Tuesday 14 August 2012

Detailed Discription of Category of Functions with Examples

Category of Functions

Category of Functions:
We have some other type of Functions where arguments and return value may be present or absent. Such functions can be categorised into:
  1. Function with arguments but no return value.
  2. Function with no arguments and return value.
  3. Functions with no arguments and no return values

So Let's have a look on Category of Functions one by one:

1. Function with Arguments but no return value: 
Here the called Function recieves the data from the calling function but the called function does not return any value back to the calling Function.So, let us understand with the help of Program:

Statement of C Program: This Program illustrates the Function with arguments but no return value:

#include<stdio.h>
#include<conio.h>
void main()
{
int a, b;
printf(" Enter the value of a and b\n");
scanf("%d%d" , &a ,&b);
largest(a, b);
}

/* Function to compute largest */

largest(c, d)
int c, d;
{
if(c>d)
{
printf(" Largest = %d\n");
}
else                                                    /* (c<d) */
{
printf(" Largest = %d\n");
}
return();
}

Output:
Enter the values of a and b
20
15
Largest = 20

                                     Function with no Arguments and Return Values                                

                                  Functions with no Arguments and no Return Values                             

0 comments:

Post a Comment