DESCRIPTIVE TYPE QUESTIONS :
- Explain the term looping.
Ans. Looping means repeated execution of a statement or a set of statements. Looping technique is used in programming to reduce the number of instructions and also memory space. In looping , we need to keep track of the number of times loop has been executed through a control variable. - Define the FOR… NEXT looping statement.
Ans. FOR… NEXT is a looping statement that has the following syntax :
FOR = TO
{ statements }
NEXT
The statements in the FOR… NEXT loop will be executed until the control variable reaches the final value. - What is the use of STEP statement in FOR…NEXT ?
Ans. STEP statement in FOR… NEXT statement increments or decrements the value of the control variable by the number specified after STEP statement.
For Eg: FOR L = 1 TO 20 STEP 3 will increment value of L to 4 , 7 , 10 , 13 , 16 , 19 in successive loops. - What is nested loop ?
Ans. A loop that is contained in another loop is called a nested loop.
• All loops must have a control variable .
• The control variable names cannot be same in the inner and outer loops.
• There can be a maximum of nine loops inside one loop.
• The inner loop must begin and end inside the outer loop. - What is the difference between WHILE…WEND and DO UNTIL ?
Ans. WHILE … WEND is a loop type that executes the statements until the given condition is TRUE.
Syntax : WHILE condition
{ statement(s) }
WEND
DO UNTIL is a loop type that executes the statements until the given condition is FALSE.
Syntax : DO UNTIL condition
{ statement(s) }
LOOP