C Function No Arguments & No Return Value



Function with no arguments and no Return Value In C

In the chapter Types of Function Calling we have seen different ways of calling function. Here is more elaborated example of Function taking no argument and not returning any value.

Live Example :

#include<stdio.h>

void area();  // Prototype Declaration
void main()
{
area();
}

void area()
{
    float area_circle;
    float rad;

    printf("\nEnter the radius : ");
    scanf("%f",&rad);

    area_circle = 3.14 * rad * rad ;

    printf("Area of Circle = %f",area_circle);
}

Output :

Enter the radius : 3
Area of Circle = 28.260000

Function Not Returning Value - Not Accepting Parameter

Explanation of the Program : Function with no Argument and Return Value

Consider main function –

void main()
{
area();
}

We have just called a function , we can see that there is no variable or anything specified between the pair of round brackets.

void area();

Now in the prototype definition (line No 3) of the function we can see the return value as Void. Void means it does not return anything to the calling function.
[box]Types of Function Calling :

  1. Function with Argument but No Return Type
  2. Function with Argument and Return Type[/box]