Computer Science, asked by apexa211180, 10 months ago

What is the function of GOSUB statement? short answer ​

Answers

Answered by mdyp2003
1

Answer:

he GOSUB statement has two forms of execution: the direct branch to a specified subroutine, and the computed branch to one of several subroutines.

When the first form is used, program control is transferred to the line starting with the specified label. Once a RETURN statement is encountered, program control transfers back to the statement following the corresponding GOSUB in the main program. The set of statements confined between the branch label and the RETURN statement constitutes an internal subroutine.

The ON...GOSUB syntax variation, or computed GOSUB, may be used to call different subroutines according to the value of expr. expr is evaluated and truncated into an integer n, and the subroutine beginning with the nth label on the statement line is given control of the program. If expr evaluates to a number less than 1 or greater than the number of statement labels listed, no action is taken.

The colon is optional in the statement label reference. Furthermore, the statement label may be anywhere in the program; that is, it may either precede or follow the referencing GOSUB statement. If the specified statement label is not found, an error message is printed at compile time.

Answered by sunny5078
3
GOSUB Statement. The GOSUB statement transfers control to the line with the specified statement label, where the program sequentially proceeds until it reaches a RETURN statement. Statement labels as described in Format, Data and Expressions. An expression evaluating to a numeric value.
Similar questions