can we take any other data type instead of "int main". | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

can we take any other data type instead of "int main".

if not why it is?.. cant be float or any others.

23rd Aug 2016, 4:30 PM
Sami Okz
Sami Okz - avatar
7 Answers
+ 3
void main
23rd Aug 2016, 6:15 PM
Gaurav Sahadev
Gaurav Sahadev - avatar
+ 1
Remember that, main is a function and functions have return types. So it depends on you. If you want to return a data type in your main, you can do it. The int is common because you most often do return 0 (an integer).
2nd Sep 2016, 1:24 PM
Bless Darah Gah
Bless Darah Gah - avatar
0
void
23rd Aug 2016, 6:21 PM
Rajat Agrawal
0
yes you can use void....but be careful because void dont return nothing...and this means that he don't need the return 0 statement to check if everything went OK and that is bad...hope that this helps ;-)
24th Aug 2016, 6:18 AM
Carlos Augusto Silva Gurgel
Carlos Augusto Silva Gurgel - avatar
0
Yes, we can use void main() too.
1st Sep 2016, 3:39 PM
Rishabh Soni
Rishabh Soni - avatar
0
thank you all of dears.
1st Sep 2016, 5:09 PM
Sami Okz
Sami Okz - avatar
0
ofcourse
3rd Sep 2016, 5:18 PM
Pradeep Kumar
Pradeep Kumar - avatar