Why we use int main() in C++ | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Why we use int main() in C++

In C ++ we start with int main() function qhy not we use only main() what is the difference

25th Oct 2020, 7:36 AM
SAADAT ALI
4 Answers
+ 3
According to C/C++ , syntax of defining a function is :- Return type_function name (arguments) And main() is no other exception. It is necessary to specify it's return type In C89, the unspecified return type defaults to int. So, main was equivalent to int main in C89. But in C99, this is not allowed and thus one must use int main.
25th Oct 2020, 8:14 AM
Arsenic
Arsenic - avatar
+ 3
They are different standards of C language. The first C standard was released 1989 nationally in USA, by their national standard institute ANSI. This release is called C89 or ANSI-C. From 1989-1990 this was "the C language". In 1999, the C standard went through a major revision (ISO 9899:1999). This version of the standard is called C99. From 1999-2011, this was "the C language" Source : https://en.wikipedia.org/wiki/C_(programming_language)
25th Oct 2020, 9:40 AM
Arsenic
Arsenic - avatar
+ 1
What is c89 and c99
25th Oct 2020, 8:31 AM
SAADAT ALI
+ 1
Thanx great information
25th Oct 2020, 12:17 PM
SAADAT ALI