answersLogoWhite

0


Best Answer

in BASIC, GOSUB and the RETURN statement allows the use of subrouteens.

User Avatar

Wiki User

12y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is function of GOSUB statement in subrouteen?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

What statement can be used to transfer control back to the main program after the execution of a subroutine?

It depends what language you are using. Structured languages provide the easiest method, simply call the function containing your subroutine and control will automatically return to the point of the call when the function ends. You can even use functions to return a value to the caller. If functions are not an option, the language might provide a gosub statement. This is similar to a goto statement but returns control to the caller, much like a function would in a structured language.


What is difference between goto and gosub in qbasic?

"GOTO" . . . goes to the line number or label indicated, continues program execution from there,forgets where it came from and never looks back."GOSUB" . . . goes to the line number or label indicated and continues program execution from there,but remembers where it came from; as soon as it reaches a "RETURN" command, returns to the commandthat immediately follows "GOSUB".


How do you write main menu pseudo code?

==== '----------------------------------------------- '*** PROGRAM: Main Menu ' LANGUAGE: QBASIC: VERSION: QB64 '----------------------------------------------- '------------------------------------------ '*** Global variable declarations list... '------------------------------------------ userKeyPress$="" '----------------------- '*** Main Program... '----------------------- DO 'this is a menu driven program... GOSUB clearScreen GOSUB printMainMenuTitleHeading GOSUB printMainMenuOptionsList GOSUB printMainMenuInstructionsHeading GOSUB printMainMenuUserInstructions GOSUB awaitUserKeyPress GOSUB checkUserKeyPress LOOP UNTIL UCASE$(userKeyPress$) = "Q" '...UCASE converts lower case to upper END '...END of program/halt program code execution '---------------------- '*** Sub-routines... '---------------------- clearScreen: CLS '...(CL)ear the output (S)creen RETURN printMainMenuTitleHeading: PRINT "MAIN MENU" PRINT "========" RETURN printMainMenuOptionsList: PRINT "Hit key: <1> for Program 1: 12 X Tables Square" PRINT "Hit key: <2> for Program 2: Select a times tables to print out" PRINT PRINT "Hit key: <Q> to Quit!" PRINT RETURN printMainMenuInstructionsHeading: PRINT "USER INSTRUCTIONS" PRINT "==============" RETURN printMainMenuUserInstructions: PRINT "In order to select from the above Main Menu options list..." PRINT PRINT "First, chose the type of program you wish to run..." PRINT "by, carefully, reading it's description." PRINT PRINT "Then, hit a corresponding single number/letter key, either: '1'/'2';" PRINT "or, alternatively, hit key: 'Q' to Quit!" PRINT PRINT "-Thank you!" RETURN awaitUserKeyPress: DO '...keep looping until when user presses any key... userKeyPress$ = INKEY$ '...store any IN-coming KEY press LOOP UNTIL userKeyPress$ <> "" RETURN checkUserKeyPress: IF userKeyPress$ = "1" THEN GOSUB program1 '...GO to named SUB-routine IF userKeyPress$ = "2" THEN GOSUB program2 '...GO to named SUB-routine RETURN program1: GOSUB clearScreen PRINT "PROGRAM 1" '(...program 1/code goes here...) GOSUB awaitUserKeyPress RETURN program2: GOSUB clearScreen PRINT "PROGRAM 2" '(...program 2/code goes here...) GOSUB awaitUserKeyPress RETURN


The arguments in an IF function are?

IF, in C and C++, is not a function - it is a statement. There are two parameters... if (expression) statement; The expression is evaluated. If it has logical result true, or arithmentic result not zero, the statement is executed; if not, the statement is not executed. The statement can be a single statement, in which it is terminated with a semi-colon, or it can be a block of statements, in which it is surrounded by braces.


In C programming language what are the so called functions statement statement block function block and expressions?

Statements are composed from expressions. A semi-colon turns an expression into a statement. A function is not a statement it is a type definition. A statement block is a compound statement, one or more statements delimited by braces, {}. A function block is the body of a function. The body must be enclosed in braces, {}.

Related questions

What statement can be used to transfer control back to the main program after the execution of a subroutine?

It depends what language you are using. Structured languages provide the easiest method, simply call the function containing your subroutine and control will automatically return to the point of the call when the function ends. You can even use functions to return a value to the caller. If functions are not an option, the language might provide a gosub statement. This is similar to a goto statement but returns control to the caller, much like a function would in a structured language.


What is a function statement?

A function statement is a block where the function is declared and defined.


What is functional statement?

A function statement is a block where the function is declared and defined.


What is difference between goto and gosub in qbasic?

"GOTO" . . . goes to the line number or label indicated, continues program execution from there,forgets where it came from and never looks back."GOSUB" . . . goes to the line number or label indicated and continues program execution from there,but remembers where it came from; as soon as it reaches a "RETURN" command, returns to the commandthat immediately follows "GOSUB".


How do you write main menu pseudo code?

==== '----------------------------------------------- '*** PROGRAM: Main Menu ' LANGUAGE: QBASIC: VERSION: QB64 '----------------------------------------------- '------------------------------------------ '*** Global variable declarations list... '------------------------------------------ userKeyPress$="" '----------------------- '*** Main Program... '----------------------- DO 'this is a menu driven program... GOSUB clearScreen GOSUB printMainMenuTitleHeading GOSUB printMainMenuOptionsList GOSUB printMainMenuInstructionsHeading GOSUB printMainMenuUserInstructions GOSUB awaitUserKeyPress GOSUB checkUserKeyPress LOOP UNTIL UCASE$(userKeyPress$) = "Q" '...UCASE converts lower case to upper END '...END of program/halt program code execution '---------------------- '*** Sub-routines... '---------------------- clearScreen: CLS '...(CL)ear the output (S)creen RETURN printMainMenuTitleHeading: PRINT "MAIN MENU" PRINT "========" RETURN printMainMenuOptionsList: PRINT "Hit key: <1> for Program 1: 12 X Tables Square" PRINT "Hit key: <2> for Program 2: Select a times tables to print out" PRINT PRINT "Hit key: <Q> to Quit!" PRINT RETURN printMainMenuInstructionsHeading: PRINT "USER INSTRUCTIONS" PRINT "==============" RETURN printMainMenuUserInstructions: PRINT "In order to select from the above Main Menu options list..." PRINT PRINT "First, chose the type of program you wish to run..." PRINT "by, carefully, reading it's description." PRINT PRINT "Then, hit a corresponding single number/letter key, either: '1'/'2';" PRINT "or, alternatively, hit key: 'Q' to Quit!" PRINT PRINT "-Thank you!" RETURN awaitUserKeyPress: DO '...keep looping until when user presses any key... userKeyPress$ = INKEY$ '...store any IN-coming KEY press LOOP UNTIL userKeyPress$ <> "" RETURN checkUserKeyPress: IF userKeyPress$ = "1" THEN GOSUB program1 '...GO to named SUB-routine IF userKeyPress$ = "2" THEN GOSUB program2 '...GO to named SUB-routine RETURN program1: GOSUB clearScreen PRINT "PROGRAM 1" '(...program 1/code goes here...) GOSUB awaitUserKeyPress RETURN program2: GOSUB clearScreen PRINT "PROGRAM 2" '(...program 2/code goes here...) GOSUB awaitUserKeyPress RETURN


What function in MS Excel which checks the logical condition of a statement?

IF function


The arguments in an IF function are?

IF, in C and C++, is not a function - it is a statement. There are two parameters... if (expression) statement; The expression is evaluated. If it has logical result true, or arithmentic result not zero, the statement is executed; if not, the statement is not executed. The statement can be a single statement, in which it is terminated with a semi-colon, or it can be a block of statements, in which it is surrounded by braces.


In C programming language what are the so called functions statement statement block function block and expressions?

Statements are composed from expressions. A semi-colon turns an expression into a statement. A function is not a statement it is a type definition. A statement block is a compound statement, one or more statements delimited by braces, {}. A function block is the body of a function. The body must be enclosed in braces, {}.


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

statement should not return a value but function returns a value


What is the function and syntax of printf statement?

it's not a statement, it's a function: len= printf (format, ...more-parameters...);


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.


Which income statement is classified by function and which one is classified by behavior?

The multi-step income statement is classified by function, and the single-step income statement is classified by behavior.