void Function

Computer Education, Training & Tutorial Resources - ComputerEducationWorld.com
Home » Free Educations » Free Programming Training » C Programming » C For Beginners »

To indicate that the function does not return a value, declare it with a return type of void.Also to declare that there is no arguments with function just write void in place of it.

Syntax :

—-void function-name( void ){ body}——
  

A simple function is,

void print_message( void )
{
printf(”This is a module called print_message.\n”);
}

Note the function name is print_message. No arguments are accepted by the function, this is indicated by the keyword void in the accepted parameter section of the function declaration. The return_data_type is void, thus data is not returned by the function.

Example :

 void squares()
{

int loop; 
for (loop=1;loop<10;loop++);
printf(”%d\n”,loop*loop);
}
 
main()
 
{
squares();

}


• • •
 



captcha PHP Script Free PHP captcha script free php
Website Design by WebWalas.com