Computer Studies
What is a counter? Explain with reference to a program.
QBASIC: Conditional Statements
15 Likes
Answer
Counters are numeric variables that are used to keep a record of the number of times a process is repeated. A counter is initialised with a numeric value. and it increases by 1 as the process starts repeating.
For example, suppose we want to print our name five times on the screen, then we use counter.
Program:
CLS
C=1
LET N$ = "TOM"
START:
PRINT N$
C = C + 1
IF C <=5 THEN GOTO START:
END
Output:
TOM
TOM
TOM
TOM
TOM
Here C is the counter variable and keeps on incrementing till it reaches 5.
Answered By
7 Likes
Related Questions
Display the output of the following QBASIC program:
CLS
A = 5
B = 10
START:
C = A + B
PRINT C
A = A + 1
IF A <=10 THEN GOTO START:
ENDDisplay the output of the following QBASIC program:
CLS
C = 3
D = C*2
START:
PRINT C,D
C = C + 2
IF C <=10 THEN GOTO START:
ENDWhat are the different types of conditional statements used in QBASIC programming? Explain.
An unconditional GOTO sets up an infinite loop. Explain with an example.