answersLogoWhite

0


Best Answer

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. By default, it will return zero.

To learn more about data science please visit- Learnbay.co

User Avatar

Learn bay

Lvl 8
2y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

10y ago

'Main' is not at all associated with the return type. Specifying a function as main means that the function is to be executed first when the class is executed. A program can have only one 'main' function.

Answer:

The C standard ISO/IEC 9899 dictates that the return type of main() should be int.

Edited by Vijay Duggirala

It is void for Java. Which means that main in java returns no value.

This answer is:
User Avatar

User Avatar

Wiki User

12y ago

The return type of main is void in Java, int in C and C++.

This answer is:
User Avatar

User Avatar

Wiki User

9y ago

In C, if a return type is required from main then it must be a int type. Otherwise it must be void. In C++, however, main always returns an int.

This answer is:
User Avatar

User Avatar

Wiki User

13y ago

You may omit the return type; it will be defaulted to int, and you will get a warning.

This answer is:
User Avatar

User Avatar

Wiki User

12y ago

It is int, but you'd better explicitly specify it.

This answer is:
User Avatar

User Avatar

Wiki User

12y ago

The main method in Java does not have a return type. It is a void return type, which means that the associated return does not have a value associated with it.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is the default return type of a function?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

What is the default return type in C and C plus plus?

No. There is no default return type for functions, it must be explicitly specified in both the function declaration and in the definition. To specify no return value, return void. To return a variant type, return void* (pointer to void). Otherwise return the exact type.


Why the return type of all the function by default is int in c?

Because int is the most common data-type in C. Don't rely on this though, always specify the return type explicitly.


Is return type can also be used in a function with return type void?

no


CAN Overloaded functions can return default values?

I'm not sure I understand you as it wouldn't make sense for a function to return a default value. Do you actually mean can a function return an argument that has a default value? If so, then yes. Any argument passed to a function, whether defaulted or not, can be returned by the same function. If the argument is passed by value then you must return it by value. If passed by reference (which cannot be defaulted) then you can either return by reference or by value. However, if you pass by non-constant reference then you can just use the reference as an output argument, and use the actual return value for some other purpose, such as reporting any error condition(s) created by the function. Overloaded functions are no different to ordinary functions, the only criteria is that each overload has an unique signature. The return value does not form any part of the signature, thus signatures cannot differ by return type alone.


What part of a function definition specifies the data type of the value that the function returns?

The function header. The return value is written before the name of the function. This return type must match the type of the value returned in a return statement.

Related questions

What is the default return type in C and C plus plus?

No. There is no default return type for functions, it must be explicitly specified in both the function declaration and in the definition. To specify no return value, return void. To return a variant type, return void* (pointer to void). Otherwise return the exact type.


What is default return type for method in java?

default return type is : true


Why the return type of all the function by default is int in c?

Because int is the most common data-type in C. Don't rely on this though, always specify the return type explicitly.


What is the return type of calloc function?

the return type is void


Is return type can also be used in a function with return type void?

no


By default what is the active tab type?

which command should you use to quickly return text to the default format


What part of a function definition specifies the data type of the value that the function returns?

The function header. The return value is written before the name of the function. This return type must match the type of the value returned in a return statement.


CAN Overloaded functions can return default values?

I'm not sure I understand you as it wouldn't make sense for a function to return a default value. Do you actually mean can a function return an argument that has a default value? If so, then yes. Any argument passed to a function, whether defaulted or not, can be returned by the same function. If the argument is passed by value then you must return it by value. If passed by reference (which cannot be defaulted) then you can either return by reference or by value. However, if you pass by non-constant reference then you can just use the reference as an output argument, and use the actual return value for some other purpose, such as reporting any error condition(s) created by the function. Overloaded functions are no different to ordinary functions, the only criteria is that each overload has an unique signature. The return value does not form any part of the signature, thus signatures cannot differ by return type alone.


How many types of function in C?

Well, it depends on what you mean by the type of a function. There are user defined functions and library functions.


Where do you use no argument no return in c function?

Where there is no need to return any type of value from a function


What is a basic structure of a c programming?

Basic structure of a C program is /* Documentation section */ /* Link section */ /* Definition section */ /* Global declaretion section */ /* Function section */ (return type) (function name) (arguments...) void main() { Declaration part Executable part (statements) } /* Sub-program section */ (return type) (function name 1) (arguments...) (return type) (function name 2) (arguments...) . . . (return type) (function name n) (arguments...) Basic structure of a C program is /* Documentation section */ /* Link section */ /* Definition section */ /* Global declaretion section */ /* Function section */ (return type) (function name) (arguments...) void main() { Declaration part Executable part (statements) } /* Sub-program section */ (return type) (function name 1) (arguments...) (return type) (function name 2) (arguments...) . . . (return type) (function name n) (arguments...)


What are default arguments in c plus plus?

Default arguments are function parameters for which a default value is implied when not explicitly stated. int foo(int x, int base=10 ) { return( x%base); } The above function assumes 'base' is 10 unless you specify otherwise when making the call. Thus calling foo(15) will return 5, as will foo(5,10), but foo(15,16) will return 15. Note that default parameters must appear after all non-default parameters in a function declaration. Once you specify a default parameter, all other parameters that follow must also have default values. Note also that when the definition of a function is split from its declaration, only the declaration should declare the default parameters: // Declaration: int foo(int x, int base=10 ); // Definition: int foo(int x, int base ) { return( x%base); }