C program calling main() function

      No Comments on C program calling main() function

Calling main() function

This program illustrate the concept of calling main() function.

  • A main() function is a complex user defined function.
  • This program will call main() function recusrsively.
  • We have used static keyword because a static int variable remains in memory even while the program is running. In other words it retain the value of variable between multiple function calls.
  • A normal variable is destroyed when a function call where the variable is declared.

#include<stdio.h>
#include<conio.h>
void main()
{
static int x=3;
 ++x;
if(x<=5)
 {
  printf("\nhello");
 }
 main();
 getch();
}

OUPUT

calling main() function


Comment below if you are facing any problem


Also read

C program to run both if and else condition
C program to print a statement without using semicolon(;)
C program sum of Two numbers without using + operator

Leave a Reply

Your email address will not be published. Required fields are marked *