by Dinesh Thakur Category: Function and Pointer

Functions may be return type functions and non-return type functions. The non-return type functions do not return any value to the calling function; the type of such functions is void. These functions may or may not have any argument to act upon. A few illustrations of such functions are given below.

void Write (void)

{printf("You need a compiler for learning C language.\n");}

The first line in the above definition may also be written as

void Write ()

Program presents an example where a void function is defined to display a message.

Illustrates a void function with void parameter list.

#include <stdio.h>

void Display(void); //Function prototype, void parameter list
void main()
{
  Display(); //the function call
} //end of main function
void Display() // Definition of Display
{
  printf("Play an outdoor game for better health.\n");
  printf("Also remember \"It is practice which makes a man/woman   perfect in programming in C.\"\n");
}

The expected output of the above program is as given below.

   Void Functions in C

Popular Article