I Know Main is a primary funtcion in C...But Is there other reason ..like why they named it as main only and not other??? ..and why we have to write main() compulsory in prgoram...Any histroy behind it??
Help ME Please.......
The function main() is most likely named "main" because it is the first function that you write which is called by the program's startup code. There is a bunch of code that you do not write which is executed first, then when it's done it calls main(). If main() were not a required function then the startup code would not know what function to call.
like why they named it as main only and not other???
That's an easy one. C inherited the name of the starting point from B.
and why we have to write main() compulsory in prgoram
A program must have a starting point. In assembly this constitutes an address offset that denotes where instructions will begin executing. In some higher level languages execution simply starts at the top of the file. Other languages like C don't allow execution statements at the top lexical level, so they define the starting point as a function with a known name and signature that the compiler or interpreter can call directly.
Ultimately, it's all about answering the question "how do I start this program?"