answersLogoWhite

0


Best Answer

No. Return statements can only appear within a function body, but they can be placed anywhere within that body. If the function returns a value, then the return statement must also return a value of the same type.

User Avatar

Wiki User

11y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Is it possible to place a return statement anywhere in 'C' program?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

Explain goto and return in c?

A return statement is used to transfer the program control flow to the function that has called the current function under execution. If the function is main, then the program returns the control flow to the operating system. The syntax for return statement is:return return-type;A goto statement is used to transfer the control flow to a particular labelled statement, not necessarily back to the calling program. There are somerestrictionson using a goto statement. For eg: the goto statement should not skip any variable declarations. The use of goto statement is usually considered as a bad programming practice. The syntax for goto statement is:goto label_name;....label_name: statements;


Is it possible to print both if statement and else statement?

Yes int main (void) { puts ("if statement"); puts ("else statement"); return 0; }


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.


Creating a program using switch statement and if and else statement?

Not that difficult... int main (int argc, char **argv) { if (argc==1) printf ("No arguments\n"); else printf ("%d arguments\n", argc-1); goto END; END: return 0; }


What is return means in programming?

A return statement exits the function in which it is declared and gives control to the calling code. Returning from the main function exits the program and gives control to the execution environment.

Related questions

Explain goto and return in c?

A return statement is used to transfer the program control flow to the function that has called the current function under execution. If the function is main, then the program returns the control flow to the operating system. The syntax for return statement is:return return-type;A goto statement is used to transfer the control flow to a particular labelled statement, not necessarily back to the calling program. There are somerestrictionson using a goto statement. For eg: the goto statement should not skip any variable declarations. The use of goto statement is usually considered as a bad programming practice. The syntax for goto statement is:goto label_name;....label_name: statements;


Is it possible to print both if statement and else statement?

Yes int main (void) { puts ("if statement"); puts ("else statement"); return 0; }


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.


Creating a program using switch statement and if and else statement?

Not that difficult... int main (int argc, char **argv) { if (argc==1) printf ("No arguments\n"); else printf ("%d arguments\n", argc-1); goto END; END: return 0; }


How do you use return?

In C/C++ programming and most other procedural languages, you use a return statement to return control to the calling function. In the case of the global main function, a returnstatement terminates the program, releasing all memory used by the program and returning control to the execution environment.Functions that return void do not return a value and therefore do not require a return statement, unless the function needs to return early (before falling off the end of the function). Functions that return values must use a returnstatement to return the appropriate value to the caller.In C++ (but not in C), the global main function does not require a return statement unless returning early. When omitted, the global main function implicitly returns the value 0 (to the execution environment) when execution falls off the end of the function. To return any other value, a return statement is required.


How does return statement work in vb?

No Return statement in VB programming


How do you write a program using goto statement?

int main (void) { puts ("Hello"); goto LABEL; LABEL: return 0; }


What is return means in programming?

A return statement exits the function in which it is declared and gives control to the calling code. Returning from the main function exits the program and gives control to the execution environment.


What do you mean by deadcode elimination?

In compiler theory, dead code elimination is a compiler optimization used to reduce program size by removing code which does not affect the program. Dead code includes code that can never be executed (unreachable code), and code that only affects dead variables, that is variables that are irrelevant to the program. Consider the following example written in C. int foo() { int a = 24; int b = 25; /* Assignment to dead variable */ int c; c = a


In a java program in a return statement with string concatenation how do you print a blank line?

use "\n" between the words where you want a new line


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.


How do you write a c program without using scan statements?

#include <stdio.h> int main (void) { puts ("What is a 'scan statement'?!"); return 0; }