why does main funtion needs "int" declaration? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

why does main funtion needs "int" declaration?

28th Jun 2016, 11:01 AM
임성균
임성균 - avatar
5 Answers
+ 1
to..
28th Jun 2016, 11:08 AM
Apoorv Bhat
Apoorv Bhat - avatar
+ 1
to... return the state of execution at the end of the program. 0 = no problem, GG! other values may refer to errors numbers. In that way, final users know, for example, that if the return is 2, there is a problem in reading files.
28th Jun 2016, 12:19 PM
Dorian
0
when you declare int function int can return only int value instead of float etc
29th Jun 2016, 12:20 AM
pankaj kirola
pankaj kirola - avatar
0
when you declare int you are specifying the data type of the function so that compiler can understand what kind of values it must accept. You may also use other data types such as void etc
1st Jul 2016, 12:21 PM
Pramod Nagaraj
Pramod Nagaraj - avatar
0
using other return type for main is not recommended and can make trouble with some compiler
1st Jul 2016, 12:40 PM
Dorian