answersLogoWhite

0


Best Answer

Not all functions return values. If you take a function which is of type void, you get a function which is does not return anything. The only functions which should return values are those which are used as a right side of expressions (so called rvalues).

User Avatar

Wiki User

15y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Why function should return a value?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Games

How do you get the red orb back from team aqua on Pokemon Sapphire?

Archie will return the Red orb himself. As you are on the top of mt. Pyre, you should return the blue orb too.


What are call by value and call by reference?

Call by value is where the argument value is copied to the formal parameter, which is then passed to the function. While the function is executing, it can see the copy of the argument, and it can modify it, if desired, but since it is a copy, it cannot modify the original argument.Call by reference is where the argument's address (or some kind of reference to it, see the clarification below) is copied to the formal parameter, which is then passed to the function. While the function is executing, it can see the original argument, and it can modify it, if desired.Note that, formally, C and C++ are always call by value. When we use so-called call by reference semantics, whether it is explicit like in C, or implicit like in C++, we are simply treating the address of the argument as the value that is copied, but when you get into the nitty gritty details of the calling sequence, it is always call by value.As a clarification, because terminology is critical here, what we do in C and C++ is actually call by value or call by address, not call by reference. The distinction is important when you get into managed heap languages like Java and .NET, where the formal parameter is actually a reference handle to some object in the heap, and not actually a value nor an address.


What is MTU value for DSI?

I'm using my hotspot for my DSi XL... What should I put my MUT value at???


How do you unpause virtual families on iPod touch?

Go to the main menu and click options. Then it should give you a list of options and pause game should be one of them. If your game is paused, the yes box should be filled. Change it to No and return to your game. It should be unpaused now.


How do you return dogz on dogz 5?

Hi um when u let yr dogz out click the little picture that will ither b pink or blue on da case and it will come up with da dogs details, u should see a 'return' button

Related questions

How does the compiler differentiate the statement and function in C programming?

statement should not return a value but function returns a value


What function should be used to add a column of numbers and return a single value?

The "SUM" function.


Why it display function should return a value in c programme?

It is up to you to decide. You may go for 'void' return type, which means no return value.


Difference in using a method that return value and method that does not return value in object orinted programming?

A method that return a value should have a return statement. The method signature should indicate the type of return value. While in the case of a method that does not return a value should not have a return statement and in the signature, the return type is void. When using a method that doesn't return a value, a programmer can not get a value from that function, but instead, it can only change variable values and run other methods.


How do you return a value in a PHP function?

Below is a simple example of how you could return a value in a PHP function. <?php function returnme($value) { return $value; } echo returnme('hello'); // outputs: hello ?>


Is function always return a value?

no, every function can not return a value. for example void name() { cout<<"Hello world"; } this function does not return any value due to the key word void that tells the compiler that the function does not returns a value.


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.


What statement returns a value from a function?

return


How do you echo the return value of a function?

echo function();


What is a return statement used for?

It means end the function. Functions automatically end when execution reaches the end of the function, but you can return from a function at any point within the function with a return statement. If the function returns a value to its caller, you must provide a reachable return statement along with the value you wish to return.


What is the difference between using a return value and a pass-by-reference parameter?

The main difference is that return values can be used in compound statements (such as assignments), whereas output parameters cannot. An output parameter is a non-const parameter that is passed by reference or as a pointer variable.As a general rule, every function should return something through the return value, even if only an error level where zero would typically indicate success (but not always). A function that does not return anything (returns void) is not strictly a function, it is better described as a procedure. However, if a function can be guaranteed never to fail (provides trivial functionality) and has no need to return any other value to the caller, then returning void is a logical option. Just because a function should return a value doesn't mean that it must return a value.However, the return value is limited by the fact that it only permits one value to be returned by a function. Output parameters allow a function to return several values at once and can be used in conjunction with the return value. If there is no need for the return value, it should be used to indicate the error level of the function wherever it would be appropriate. However it is not unusual for a function to accept a reference as an output parameter and to also return that same reference via the return value.Note that although you could return multiple values via a struct or class type, this should only be considered if you have several functions that can make use of the struct or class type. However, in most cases it would be simpler to make those functions members of the struct or class itself.


How do you rectify the waring is function should return a value in turbo c plus plus?

By returning a value. Or using type 'void'.