No Arguments and No Return Values Function

This “No Arguments and No Return Values Function” page explains clearly about how to define a function in C program which is not taking input and not returning any data.


 

No arguments and No return values function :

  • Argument specifies input of function.
  • “void” data type specifies the word “nothing”.
  • The above classification can be described technically using “void” data type only.

 

#include<stdio.h>
void display(void); –>prototype
void main()
{
printf(“ctrl in main \n”);
display(); –>function call
printf(“ctrl back to main \n”);
}
void display() –>function definition
{
printf(“ctrl in display”);
}

 

Check out this code :
#include<stdio.h>
void display(void);
void show(void);
void main(void)
{
printf(“ctrl in main \n”);
display();
printf(“ctrl back to main \n”);
show();
printf(“end of main\n”);
}
void show(void)
{
printf(“ctrl in show\n”);
display();
printf(“ctrl back to show\n”);
}
void display(void)
{
printf(“ctrl in display\n”);
}

Share this