Digital Learning

Sunday, January 16, 2022

CBSE Computer-Science Class-VII (Solved Exercise-8):

Computer Science
Class-VII
Chapter- 8 QBASIC Programming Statements

Section-1

A. Answer these questions orally:
1. What is step value in the syntax of FOR......Next statement?
Answer: Step Value is the amount by which the counter is changed each time through the loop.

2. What is used to control execution of a DO WHILE....LOOP?
Answer: A counter variable is used to control execution of a DO WHILE...LOOP.

3. What is used to come out of a loop before the expected number of executions?
Answer: To come out of a loop before the expected number of execution, EXIT command is used followed by either FOR or Do.

B. Tick the correct options:
1. A loop is used to repeat a block of statements a _____ number of times.
a. any        b. specific        c. unknown        d. ten
Answer: Specific

2. In a decrementing loop the starting number is greater than the ____ number.
a. ending    b. middle        c. bigger            d. smaller
Answer: ending

3. Every DO WHILE loop ends with the _____ statement.
a. POOL        b. LOOP        c. COOL            d. MOON
Answer: LOOP

Section-2
A. Fill in the blanks:
1. FOR...NEXT is a ____ type of QBASIC statement.
Answer: Loop

2. ______ is used to end DO loop.
Answer: Loop counter

3. ______ works similar to DO......WHILE.
Answer: Exit controlled loop

4. ______ is used to repeat certain steps a fixed number of times.
Answer: For loop

5. The DO...... LOOP can be used either with WHILE statement or ____ statement.
Answer: UNTIL

D. Differentiate between:
1. FOR.....NEXT and DO WHILE loop.
Answer: For Next is a set of statements to be repeated for a given number of times.
Do While Loop: This statement repeats a block of statements while a condition is true.

2. DO WHILE and DO UNTIL loop.
Answer: 
DO WHILE: This statement repeats a block of statements while a condition is true.
DO UNTIL.. is different from DO WHILE .... as it executes the statements until the condition is true.

3. DO UNTIL and WHILE....WEND loop.
Answer: 
DO UNTIL.. is different from DO WHILE .... as it executes the statements until the condition is true.
WHILE WEND: If the condition is placed at the end of loop, the end of loop is executed at least once.

4. Start value and End value in a syntax.
Answer: 
Start Value is the initial value of the counter variable.
End Value is the value that the counter variable must exceed to exit the loop.

E. Answer the following questions:
1. What is iteration in QBASIC? Give example.
Answer: The process of repetition is called iteration.
Example:
FOR counter_variable=StartValue to EndValue STEP StepValue.
Statement 1;
Statement 2;
Next counter_variable.

2. Why do you use FOR.....NEXT? Write a small code to support your answer.
Answer: For...Next structure is used when you want to perform a loop a specific number of times.
Example:
FOR counter_variable=StartValue to EndValue STEP StepValue.
Statement 1;
Statement 2;
Next counter_variable.

3. What is the purpose of WHILE...WEND in QBASIC? Write a small code.
Answer: The purpose of DO....LOOP and WHILE.....WEND is similar except for the syntax. If the condition is placed at the end of loop, the end of loop is executed at least once.
Syntax:
WHILE test condition
Statements
WEND

4. What is the difference between a DO WHILE and a DO UNTIL statement?
Answer: 
DO WHILE: It performed as long as the condition being tested is true.
DO UNTIL: It executes the statements until the condition is true.

5. Why do you use EXIT command? Give example.
Answer: Exit command is used to come out of a loop before the expected number of executions. Exit command is used followed by either FOR or DO.


No comments:

Post a Comment