Sarojsir.com

collapse
...
Home / Class X / Lesson 9-Review of Control Statement SOLVED | Class 10

Lesson 9-Review of Control Statement SOLVED | Class 10

May 03, 2024  SAROJ BHATTARAI  5,652 views
Lesson 9-Review of Control Statement SOLVED | Class 10

Chapter - 9
Review of Control Statement


📚EXERCISES


1. Answer the following questions.

a. What do you mean by flow of program?

Ans: The order of execution of statements of a program is known as program control or flow of program.

b. What is control structure?

Ans: The statement of the structure that is used to handle different condition and iteration is known as control structure. It is used for controlling the flow of program.

c. What is looping statement? List the looping statements that are used in QBASIC.

Ans: The statement which repeats the program until the criteria get fulfilled is k own as looping statement. Some main looping statement that are used in QBASIC are as follows:

  • FOR...NEXT
  • WHILE...WEND
  • DO...LOOP

2. Debug the following programs:

a. REM program to display odd or even.

CLS
INPUT "Enter a number"; N
R= N/2
IF R=1 THEN
PRINT "N is even"
ELSE IF
PRINT "N is odd."
END

Debugged Program

CLS
INPUT "Enter a number"; N
IF N MOD 2 = 0 THEN
PRINT "N is even"
ELSE
PRINT "N is odd."
END IF
END

b. REM Program to display pass or fail.

CLS
INPUT "Enter marks of three subjects"; a; b; c
IF (a AND b AND c)≥32 THEN
PRINT "Pass"
ELSE
PRINT "Fail"
END

Debugged Program

CLS
INPUT "Enter marks of three subjects"; a, b, c
IF (a AND b AND c)≥32 THEN
PRINT "Pass"
ELSE
PRINT "Fail"
END

c. REM Program to display square and square root of a number.

CLS
FOR P = 1 TO 5
INPUT "Enter a number"; N$
PRINT P^2, P^ 1/2
NEXT P
END

Debugged Program

CLS
INPUT "Enter a number"; N
PRINT N^2, N^ 1/2
END

d. REM Program to displays cube and cube root of numbers from 9 to 27.

CLS
INPUT "Enter a number "; N
FOR P = 9 TO 27
C =N^3
CROOT=N^1/3
PRINT C, CROOT
NEXT P
END

Debugged Program

CLS
FOR P = 9 TO 27
C =P^3
CROOT=P^1/3
PRINT C, CROOT
NEXT P
END


3. Write the output of the following programs.

a. 

CLS
N = 7
FOR P = 1 TO 5
PRINT N
If N MOD Z = 0 THEN
N = N / 2
ELSE
N=N* 3 - 1
END IF
NEXT P
END

Output

???

b. 

CLS
N=9
DO
IF N MOD 2 = 1 THEN PRINT N
N = N-1
LOOP WHILE N>=3
END

Output

???

c. 

CLS
N=8
C=1
DO
F = N MOD C
IF F = 0 THEN PRINT C
N = N - 1
C = C + 1
LOOP WHILE <=8
END

Output

???

4. Write a program that accepts three numbers and displays the smallest number. 

CLS
INPUT "Enter the first number"; a
INPUT "Enter the second number"; b
INPUT "Enter the third number"; c
IF a < b AND a < c THEN
PRINT "The smallest number is "; a
ELSEIF b < a AND b < c THEN
PRINT "The smallest number is "; b
ELSE
PRINT "The smallest number is "; c
END IF
END

5. Write a program that accepts three numbers and displays the greatest numbers.

CLS
INPUT "Enter the first number"; a
INPUT "Enter the second number"; b
INPUT "Enter the third number"; c
IF a > b AND a > c THEN
PRINT "The greatest number is "; a
ELSEIF b > a AND b > c THEN
PRINT "The greatest number is "; b
ELSE
PRINT "The greatest number is "; c
END IF

END

6. Write a program that accepts a number and displays whether number is positive, negative or zero. [Hint: >0 is +ve and <0 is -ve]

CLS
INPUT "Enter a number: ";N
IF N > 0 THEN
PRINT "The number is Positive."
ELSEIF N < 0 THEN
PRINT "The number is Negative."
ELSE
PRINT "The number is Zero."
END IF
END

7. write a program that accepts length of three different rods and displays whether a triangle can be formed or not by using the rods. [Hint: A triangle can be formed if the sum of two sides is greater than third side]

CLS
INPUT “ENTER THREE SIDES OF A TRIANGLE”; A,B,C
IF (A + B) > C AND (B + C) > A AND (A + C) > B THEN
PRINT “THE TRIANGLE CAN BE FORMED”
ELSE
PRINT “THE TRIANGLE CANNOT  BE FORMED”
END IF
END

8. Write a program that accepts three numbers and displays the middle number among them on the basis of value. [Hint: If the numbers are 5, 7, and 2 then the middle number is 5.]

CLS
INPUT “ENTER ANY THREE NUMBERS”; A, B, C
IF A > B AND A < C OR A < B AND A > C THEN
PRINT A; “IS MIDDLE NUMBER”
ELSEIF B > A AND B < C OR B < A AND B > C THEN
PRINT B; “IS MIDDLE NUMBER”
ELSE
PRINT C; “IS MIDDLE NUMBER”
END IF
END

9. Write a program that asks a user to input principal amount and number of years. The program calculates and displays the simple interest on the basis of the following rates.

Number of YearsRate
 <2 2.5
 >= 2 and <4 5
 >=4 9.5

INPUT " Enter Principal"; P
INPUT "Enter Time"; T
IF T< 2 THEN
I = (P*T*2.5)/200
ELSE IF T >= 2 and T < 4 THEN
I = (P*T*5)/100
ELSE
I = (P*T*9.5)/100
PRINT "The simple interest is "; I
END IF
END

10. Write a program that displays even numbers form 2 to 24. 

CLS
FOR I = 1 TO 40 STEP 2
PRINT I;
NEXT I
END

11. Write a program that displays first twenty odd numbers.

CLS
FOR I = 2 TO 24 STEP 2
PRINT I;
NEXT I
END

12. Write a program that displays square, square root and cube root of numbers from 1 to 10.

CLS
FOR I = 1 TO 10
PRINT I^2, I^1/2, I^1/3
NEXT I
END

13. Write a program that displays sum of first ten counting numbers.

CLS
FOR I = 1 TO 10
SUM = SUM + I
NEXT I
PRINT "THE SUM OF FIRST TEN COUNTING NUMBER IS"; SUM
END

14. Write a program that asks to input any ten numbers and displays sum of them.

CLS
FOR I= 1 TO 10
INPUT "ENTER THE NUMBERS"; N
S=S+N
NEXT I
PRINT "SUM OF 10 NUMBERS"; S
END

15. Write a program that reads ten numbers from the list of numbers and displays sum of even numbers of them. The list of numbers contains: 4, 2, 3, 7, 17, 18, 41, 36, 86 and 19.

Answer not available... if you know then let us know.

16. Write a program to find the frequency of data divisible by 3 and 5 among the data given as: 15, 12, 14, 30, 45, 41, 36, 42 and 60.

Answer not available... if you know then let us know.

17. Write a program that reads seven numbers from the list of numbers and displays the greatest number among them. The list of numbers contains 45, 65, 12, 68, 87, 122 and 564.

Answer not available... if you know then let us know.


18. Write programs to generate following number series:

a. 1, 4, 7, 10, ...... up to 15 terms

CLS
A = 1
B = 3
for I = 1 to 15
PRINT A
A = A + B
Next I
END

b. 1, 4, 7, ........ 34

CLS
FOR I = 1 TO 34 STEP 3
PRINT I
NEXT I
END

c. 3, 5, 7, ..... up to 11 terms

CLS
A = 3
B = 4
FOR I = 1 TO 11
PRINT A
A = A + B
NEXT I
END

d. 3, 5, 7, ..... 25

CLS
FOR I = 3 TO 25 STEP 2
PRINT I
NEXT I
END

e. 100, 90, 80, .... 10

CLS
FOR I = 100 TO 10 STEP -10
PRINT I
NEXT I
END

f. 1, 4, 9, ..... ,121

CLS
FOR I = 1 TO 11
PRINT I^2
NEXT I
END

g. - 10, - 8, - 6, ...... up to 15 terms

CLS
A = -10
FOR I = 1 TO 15
PRINT A


Share:

Leave a comment

Your email address will not be published. Required fields are marked *