Hunt for India's Best Academic Project (Applications Open)

CrazyEngineers has announced Hunt for India's Best Academic Project - a mega projects competition open to all THIRD and FINAL year engineering students from ALL engineering branches. Prizes worth Rs. 80,000+ are ready to be won!


Deadline: 28 February 2015 (11:59 PM)  


Click: Read Contest Details || Click To Submit Your Entry

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

    Engineering Discipline:
    IT
    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???
     
    #1
  2. Deepika Bansal

    Engineering Discipline:
    Computer Science
    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
    #2
  3. Rahul Naraniya

    Rahul Naraniya Apprentice

    Engineering Discipline:
    IT
    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??
     
    #3
  4. beingab

    beingab Rookie

    Engineering Discipline:
    Computer Science
    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
     
    #4
  5. Rahul Naraniya

    Rahul Naraniya Apprentice

    Engineering Discipline:
    IT
    ohk... got it thanks... :)
     
    #5
  6. ravirajput

    ravirajput Newbie

    Engineering Discipline:
    Computer Science
  7. SK Jindal

    SK Jindal Newbie

    Engineering Discipline:
    Electronics & Communications
    void implies no return type and int main means that main() will return an integer
     
    #7

Share This Page