C Program Without Main Function

Yes, you read it right. Seems impossible ? Nothing is impossible. Though it seems meaningless to write C Program without main Function . Every Program Must have Main Function as it is Entry Point of Every C Program. All Predefined and User-defined Functions are called directly or indirectly through the main.

Below is the program to write C program without main function

#include<stdio.h>

#define begin main

int begin() {

printf(“Hello”);

return (0);

}

Save C Program using Extension .C

 Explanation to the program :

•          Before Program is given to compiler program is processed by Preprocessor .

•          Source Program is scanned from Left to Right and from Top to Bottom and “begin” is replaced by “main”

 

Mohit Arora
Follow me