Computer Studies

An unconditional GOTO sets up an infinite loop. Explain with an example.

QBASIC: Conditional Statements

7 Likes

Answer

A GOTO statement directs the control to transfer the desired label to set up a loop. An unconditional transfer of control sets up an infinite loop, from where there is no exit.

Example:

CLS
A = 1
START:
PRINT A
A = A + 1
GOTO START:
END

Here, after the value of A is incremented, the control transfers to the label unconditionally. So, this GOTO sets up an infinite loop.

Answered By

3 Likes


Related Questions