answersLogoWhite

0

Yes, there is no limit.

User Avatar

Wiki User

15y ago

What else can I help you with?

Continue Learning about Engineering

What is return in programming?

The return statement is used in functions to return control to the caller. If the function is declared non-void, the return statement also allows the programmer to return a value to the caller.


Is it possible for a function to return more than one value at a time?

No, you can only return one value with a return statement. However, you can return a structure or pointer, so the real answer is yes, though requiring some added complexity.


Can a function in Python return more than one value?

Yes, a function in Python can return more than one value by using tuples, lists, or dictionaries. When multiple values are returned, they are typically packed into a tuple by default, which can then be unpacked by the caller. For example, a function can return two values like this: return value1, value2. The caller can capture these values using multiple assignment, such as a, b = my_function().


What is inner returns in c plus plus?

Inner returns is not part of standard terminology, so it's difficult to say exactly what it means. It sounds as though it means a return statement other than the one that would typically appear as the final statement in a function. For instance: int foo(int x) { if(!x) return(-1); // inner return? return(x*x); // typical return? } Differentiating return statements in this way is somewhat meaningless. All we're really saying is that the function has multiple return paths, in this case 2 distinct return paths. A more complex function might have several return paths, some more deeply nested than others, but it makes no real difference, so long as every reachable path has a return statement. In some cases, a function may not have a final return statement at all, simply because the function is guaranteed to never reach that point, because all possible routes through the function lead to an "inner" return path. For example: int foo(int x) { if(!x) return(-1); switch(x) { case(1): return(x); case(2): return(x*x); default: return(x*x*x); } } In the above example, there is no return statement before the final closing brace, because the code is guaranteed never to reach that point. All the return paths are "inner" returns. We could just as easily write the exact same function as follows: int foo(int x) { switch(x) { case(0): return(-1); case(1): return(x); case(2): return(x*x); defaut: return(x*x*x); } } Or this way: int foo(int x) { switch(x) { case(0): return(-1); case(1): return(x); case(2): return(x*x); } return(x*x*x); } The logic is the same in each case, it's just a question of which is easier to read and understand. Out of all three, the second is perhaps the simplest to understand because all the logic is contained within the switch statement. But as far as the compiler is concerned, there should be no difference. A good optimiser should compile all three with exactly the same assembly instructions.


How does the compiler interpret more than one definition of the same name?

The compiler disambiguates function overloads by their signatures. A function's signature is defined by its name and its formal parameters, but not the return type. As you probably know, function overloads cannot differ by return type alone, thus the return type does not form any part of the signature. The compiler determines which function to call based upon the arguments that are passed by the individual callers.

Related Questions

Why a return function does not return more than one value?

It's by design.


What is return in programming?

The return statement is used in functions to return control to the caller. If the function is declared non-void, the return statement also allows the programmer to return a value to the caller.


Is it possible for a function to return more than one value at a time?

No, you can only return one value with a return statement. However, you can return a structure or pointer, so the real answer is yes, though requiring some added complexity.


What is the need for return statements in c?

It's not so much a need but a requirement. Every C function must contain at least one return statement, typically at the end of the function body (before the closing brace). However, a C function may have more than one return path, and each requires its own return statement. Note that it does not matter whether the function returns a value or not; even a function that returns void must have a return statement. In C++ the rules regarding return statements are more relaxed. Functions that return void do not require a return statement at all; when execution reaches the closing brace of a void function, a return statement is implied. All functions that return a value of any type other than void must have a return statement. The one exception to this rule is the global main function which must always return an int. If the global main function has no return statement then the value 0 is implicitly returned to the calling environment (the value 0 is typically used to indicate no error). However, if we need to return other values (including 0), then we must include a return statement. Functions that have multiple return paths are considered poor style and should be avoided. Functions are generally much easier to read and maintain when there is only one return path which should logically terminate at the very end of the function. However, eliminating multiple return paths can also produce more efficient machine code, particularly in functions with highly complex return paths. Eliminating multiple return paths needn't be difficult, we simply need to refactor the function such that each unique return path is representing by some function which returns the appropriate value. The calling function simply stores that value and returns it at the end of the function, thus simplifying the overall complexity of the calling function. Refactoring complex functions into smaller, simpler function calls is good style in and of itself; well-named, descriptive function calls result in code that is largely self-documenting and thus more abstract. Although function calls are themselves expensive, small and simple functions can be easily inline-expanded by the compiler's optimisers, so it's a win-win.


What statement causes a function to executed in PHP?

All usable statements in PHP can cause a function to be executed - however, that's not to say that every statement will execute a function. A statement is defined by the programmer, who it is ultimately the one responsible for including a function, more than one function, or no functions.


Can a function in Python return more than one value?

Yes, a function in Python can return more than one value by using tuples, lists, or dictionaries. When multiple values are returned, they are typically packed into a tuple by default, which can then be unpacked by the caller. For example, a function can return two values like this: return value1, value2. The caller can capture these values using multiple assignment, such as a, b = my_function().


Explain the all control statement in c plus plus language and give Examples?

A control statement is any statement that alters the normal flow of execution. C++ code normally executes procedurally from the top down, however when invoking functions, execution branches off to the function code before returning to the instruction immediately after the function call. A compound statement may consist of several function calls, however even a simple statement may incur more than one function call, where the result of one function provides the argument for another. Decision-making statements like if, if-else and switch can also be used to control the flow of execution, as can the ternary operator (?:). Loops such as for, while and do-while are also examples of control statements. Other examples include goto, break, continue, return, abort and exit, often used in conjunction with decision-making statement. Functions that return void also allow execution to "fall off the end" of the function, which is essentially an implicit return statement. The global main function is the only non-void function that can "fall off the end" (implicitly returning the integral value 0).


What is the use of pointer?

To point with. 1. To manipulate parts of an array. 2. To return more than value from a function.


What is inner returns in c plus plus?

Inner returns is not part of standard terminology, so it's difficult to say exactly what it means. It sounds as though it means a return statement other than the one that would typically appear as the final statement in a function. For instance: int foo(int x) { if(!x) return(-1); // inner return? return(x*x); // typical return? } Differentiating return statements in this way is somewhat meaningless. All we're really saying is that the function has multiple return paths, in this case 2 distinct return paths. A more complex function might have several return paths, some more deeply nested than others, but it makes no real difference, so long as every reachable path has a return statement. In some cases, a function may not have a final return statement at all, simply because the function is guaranteed to never reach that point, because all possible routes through the function lead to an "inner" return path. For example: int foo(int x) { if(!x) return(-1); switch(x) { case(1): return(x); case(2): return(x*x); default: return(x*x*x); } } In the above example, there is no return statement before the final closing brace, because the code is guaranteed never to reach that point. All the return paths are "inner" returns. We could just as easily write the exact same function as follows: int foo(int x) { switch(x) { case(0): return(-1); case(1): return(x); case(2): return(x*x); defaut: return(x*x*x); } } Or this way: int foo(int x) { switch(x) { case(0): return(-1); case(1): return(x); case(2): return(x*x); } return(x*x*x); } The logic is the same in each case, it's just a question of which is easier to read and understand. Out of all three, the second is perhaps the simplest to understand because all the logic is contained within the switch statement. But as far as the compiler is concerned, there should be no difference. A good optimiser should compile all three with exactly the same assembly instructions.


Is this statement Inflation is more harmful to the economy than unemployment a positive statement?

equality is more important than efficiency. Is that a positive or normative statement?


Can you call a function inside an echo statement in PHP?

Of course it is possible to call a PHP-function inside an echo statement. The function will be executed and returns a value. This value then is used in the echo statement. For example: echo "Ferengi-Rule #1: ", ferengi_rule(1), "\n"; echo "Random: ", ferengi_rule(0), "\n"; function ferengi_rule($number) { $rules = array( 1 => "Once you have their money, never give it back.", 2 => "You can't cheat an honest customer, but it never hurts to try.", 3 => "Never buy anything for more than is absolutely necessary.", 4 => "Sex and profit are the two things that never last long enough." // ... ); if( isset($rules[$number]) ) { return $rules[$number]; } else { return array_rand($rules); } }


How does the compiler interpret more than one definition of the same name?

The compiler disambiguates function overloads by their signatures. A function's signature is defined by its name and its formal parameters, but not the return type. As you probably know, function overloads cannot differ by return type alone, thus the return type does not form any part of the signature. The compiler determines which function to call based upon the arguments that are passed by the individual callers.