+ 3

Why can't we use void main () instead of int main ()

20th Jul 2019, 4:05 AM
Merlyn J
12 odpowiedzi
+ 8
Because there is a return type. From what I know the integer returned tells the status of the given operation, whether the main function executed alright or terminated abnormally.
20th Jul 2019, 4:10 AM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 6
Void main is used when the main() function doesn't return anything. But in modern compilers void main() results in an error. It works in Turbo c++.
20th Jul 2019, 5:25 AM
Manoj
Manoj - avatar
+ 5
Yes. Because of how C++ works.
20th Jul 2019, 4:13 AM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 5
advanced compilers demands the return of a value... after the execution of program
20th Jul 2019, 4:50 AM
Aditya
Aditya - avatar
20th Jul 2019, 4:26 AM
Sonic
Sonic - avatar
+ 2
So we can't use void main () for programs?
20th Jul 2019, 4:12 AM
Merlyn J
+ 2
Both are correct! 🤔
21st Jul 2019, 9:36 AM
Sanjay Kamath
Sanjay Kamath - avatar
+ 1
merlynnoel25 Actually no, in other functions & classes except main() you can use void main()
21st Jul 2019, 8:58 AM
mhb
+ 1
we can also use void main but the difference between void main and int main is that void main does not retrun anythings because it is void and int main will return a integer value
22nd Jul 2019, 6:25 PM
Sami
Sami - avatar
0
So basically with functions and classes everything, we only have to use int main () not void main () in c++ right??
20th Jul 2019, 4:33 AM
Merlyn J
0
Because operating system can understand only 0s and 1s only int contains 0 and 1 so we use int
1st Aug 2019, 12:56 AM
hema chowdhary
hema chowdhary - avatar