C programming language, c++ language, Education, Engineering Course, programming language

What-are the different ways to write main functions in Programming? tccicomputercoaching.com

main() is main function in Programming Language where coding should be done.

function-programming_smiple

There are different ways to write this main function.

1. void main()

  • The return type of the function “main” is void, i.e. it does not return anything to the OS.
  • Nothing has been said about the arguments in main, which means that you can either pass the arguments to main or not pass anything at all.

2. int main(void)

  • The return type of the function is “int”, i.e. it is supposed to return an integer value to the OS.
  • “void” means that you’re not allowed to pass any argument to the main. Doing this would result into a compiler

3. int main()

  • The return type of the function is “int”, i.e. it is supposed to return an integer value to the OS.
  • Nothing has been said about the arguments in main, which means that you can either pass the arguments to main or not pass anything at all

4. void main(void)

  • The return type of the function “main” is void, i.e. it does not return anything to the OS.
  • “void” means that you’re not allowed to pass any argument to the main. Doing this would result into a compiler error.

To read other topics visit us@ http://tccicomputercoaching.com/blog/

Enrol at TCCI to learn Programming Languages.

call us @ 98256 18292.

 

Leave a comment