Computer Science, asked by jageesha, 1 year ago

Where we use main and void main in c program

Answers

Answered by kvnmurty
3
when we define the main program as just
      main ()  or  int  main()
then it is possible that the function main()  returns a status value or an important computation result to the shell (command.com or ksh or csh programs) in the operating system.  In a batch file  (*.bat) , this return value is used to find the success or failure of the program.  Or, some computed value is passed from the program to the user involving the program at the shell prompt.  Often batch files are stopped if one program fails in between and takes an input from the user running the batch file.

=========

When one defines as
        void  main ()

  then the programmer knows that the this function does not return any value to the shell invoking the program.  The shell does not know if the program succeeded or not.


kvnmurty: click on thank you link and select best answer
Similar questions