Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can main() function return double?

Tags:

c

return-type

Can the main() function in a C program return a double data type?

If Yes, how and why?

If No, why?

like image 678
rajvelu Avatar asked May 23 '10 06:05

rajvelu


People also ask

Can a main function return?

The return value of main() function shows how the program exited. The normal exit of program is represented by zero return value. If the code has errors, fault etc., it will be terminated by non-zero value. In C++ language, the main() function can be left without return value.

Can you return a double in C?

Data type double is larger than char, hence, double return type is large enough to hold a char value and return it from the function.

Can main function return string?

Not possible with same method arguments. Method overloading is defined by argument type and count not by return type. The exception is telling you can't, so no you can't.

What is double main in C++?

C++ double data type can be either fractional as well as whole numbers with values. These kinds of decimal oriented data type value can contain numbers till 15 digits and can either be prefixed with the decimal point or can be suffixed with the decimal point.


1 Answers

Yes. According to C standard, main() should return a int value. But not must.

See here.

like image 188
Yin Zhu Avatar answered Oct 22 '22 06:10

Yin Zhu