Hunt for India's Best Academic Project Contest - 2015

Important Links To Visit: 


Click: List of Shortlisted Participants | Click: Round II Details (Important) 


Difference between int main and void main in C programming language?

Discussion in 'Computer Science | IT | Networking' started by Rahul Naraniya, Jul 19, 2014.

  1. Rahul Naraniya

    Rahul Naraniya Apprentice

    can anyone explain what is difference between int main and void main??? why it is suggested to use int main instead of void main?? and why we need #include<conio.h> when we use int main???
  2. Difference betwèen int main and void main: See like any other function, main is also a function but with a special characteristic that the program execution always start from main. So the function main needs arguments and a return type. These int and void are its return type. Void means it will not return any value, which is also ok.
    But if want to know whether the program has terminated successfully or not, we need a return value which can be zero or a non zero value. Hence the functuon becomes int main () and is recommended over vpid main ().
    Hope its helps you.
    • Like Like x 2
  3. Rahul Naraniya

    Rahul Naraniya Apprentice

    The same thing we can do by using getch() (for void main). then why int main is suggested?? is there any advantage of int main over void main??
  4. beingab

    beingab Rookie

    the standard statements are:
    int main(void)
    int main(int argc, char **argv)

    You can also use main() simply that means same as int main()..
    int main() returns an exit value to compiler and works on most compilers.
    And getch() as you mentioned has nothing to do with it. It gets character input on screen or else holds screen in other words
  5. Rahul Naraniya

    Rahul Naraniya Apprentice

    ohk... got it thanks... :)
  6. ravirajput

    ravirajput Newbie

    goood yr...
  7. SK Jindal

    SK Jindal Newbie

    void implies no return type and int main means that main() will return an integer

Share This Page