The VOID keyword.


The void keyword allows us to create functions that either do not require any parameters or do not return a value.

The following example shows a function that does not return a value.


	void Print_Square(int Number);

	main()
	{
	   Print_Square(10);
	   exit(0);
	}
	
	void Print_Square(int Number)
	{
	   printf("%d squared is %d\n",Number, Number*Number);
	}

The next example shows a function that does not require any parameters:


	#include 
	#include 

        int Random(void);

        main()
        {
           printf("A random number is %d\n", Random());
           exit(0);
        }

        int Random(void)
        {
	   srand((unsigned int)time((time_t *)NULL));
	   return( rand());
        }


Example:

void example

See also:

Functions Void pointers


Top Master Index Keywords Functions


Martin Leslie