You’ll get the complete notes on the Review of Control Statement for Class 10 Computer, including detailed explanations and examples to help you understand all the fundamental concepts effectively.

## 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:

### 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**

7

20

10

5

14

**b. **

CLS

N=9

DO

IF N MOD 2 = 1 THEN PRINT N

N = N-1

LOOP WHILE N>=3

END

**Output**

9

7

5

3

**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**

1

3

**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 Years | Rate |
---|---|

<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.**

CLS

DIM numbers(10)

numbers(1) = 4

numbers(2) = 2

numbers(3) = 3

numbers(4) = 7

numbers(5) = 17

numbers(6) = 18

numbers(7) = 41

numbers(8) = 36

numbers(9) = 86

numbers(10) = 19

sum_of_evens = 0

FOR i = 1 TO 10

IF numbers(i) MOD 2 = 0 THEN

sum_of_evens = sum_of_evens + numbers(i)

END IF

NEXT i

PRINT “Sum of even numbers: “; sum_of_evens

END

**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.**

CLS

frequency = 0

IF 15 MOD 3 = 0 AND 15 MOD 5 = 0 THEN frequency = frequency + 1

IF 12 MOD 3 = 0 AND 12 MOD 5 = 0 THEN frequency = frequency + 1

IF 14 MOD 3 = 0 AND 14 MOD 5 = 0 THEN frequency = frequency + 1

IF 30 MOD 3 = 0 AND 30 MOD 5 = 0 THEN frequency = frequency + 1

IF 45 MOD 3 = 0 AND 45 MOD 5 = 0 THEN frequency = frequency + 1

IF 41 MOD 3 = 0 AND 41 MOD 5 = 0 THEN frequency = frequency + 1

IF 36 MOD 3 = 0 AND 36 MOD 5 = 0 THEN frequency = frequency + 1

IF 42 MOD 3 = 0 AND 42 MOD 5 = 0 THEN frequency = frequency + 1

IF 60 MOD 3 = 0 AND 60 MOD 5 = 0 THEN frequency = frequency + 1

PRINT “Frequency: “; frequency

END

**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.**

CLS

G = 45

IF 65 > G THEN G = 65

IF 12 > G THEN G = 12

IF 68 > G THEN G = 68

IF 87 > G THEN G = 87

IF 122 > G THEN G = 122

IF 564 > G THEN G = 564

PRINT “Greatest number: “; G

END

**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

A = A + 2

NEXT I

END

**h. 1, 2, 4, 7, …… up to 15 terms**

CLS

A = 1

FOR I = 1 TO 15

PRINT A

A = A + I

NEXT I

END

**i. 3, 5, 8, 12, 17, ….. up to 15 terms.**

CLS

A = 3

B = 2

FOR i = 1 TO 15

PRINT A

A = A + B

B = B + 1

NEXT I

END

**j. 1, 8, 27, ….. 1000.**

CLS

FOR i = 1 TO 10

PRINT i ^ 3

NEXT i

END

**k. 5, 40, 300, 2000, 10000.**

CLS

FOR I = 5 TO 1 STEP -1

PRINT I*10^P

P = P+1

NEXT I

END

**l. 7, 70, 700, 7000, 7000.**

CLS

N = 7

FOR I = 1 TO 5

PRINT N

N = N*10

NEXT I

END

**m. 1, 11, 111, 1111, 11111.**

CLS

N = 1

FOR I = 1 TO 5

PRINT N

N = N*10 + 1

NEXT I

END

**n. 33333, 3333, 333, 33, 3.**

CLS

N = 33333

FOR I = 1 TO 5

PRINT N

N = N\10

NEXT I

END

**o. 1, 22, 333, 4444, 55555.**

CLS

FOR I = 1 TO 5

For J = 1 TO I

PRINT I

NEXT J

PRINT

NEXT I

END

**p. 2, 8, 18, 32, …. up to 9 terms.**

CLS

FOR I = 1 TO 9

PRINT i ^ 2 * 2;

NEXT I

END

**q. 3, .3, .03, .003, .0003.**

CLS

A = 3

FOR I = 1 TO 5

PRINT A;

A = A / 10

NEXT I

END

### 19. Write the program to generate the following Fibonacci series:

**a. 1, 1, 2, 3, 5, 8, ……. up to 15 terms.**

CLS

A = 1

B = 1

FOR I = 1 TO 15

PRINT A

C = A + B

PRINT C

A = B

B = C

NEXT I

END

**b. 2, 2, 4, 6, 10, ….. up to 12 terms.**

CLS

A = 2

B = 2

FOR I = 1 TO 12

PRINT A

C = A + B

PRINT C

A = B

B = C

NEXT I

END

**c. 1, 3, 4, 7, 11, 18, ….. up to 15 terms.**

CLS

A = 1

B = 3

FOR I = 1 TO 15

PRINT A

C = A + B

PRINT C

A = B

B = C

NEXT I

END

**d. 3, 5, 8, 13, …… up to 15 terms.**

CLS

A = 3

B = 5

FOR I = 1 TO 15

PRINT A

C = A + B

PRINT C

A = B

B = C

NEXT I

END

**e. 1, 4, 5, 9, 14, ….. up to 16 terms.**

CLS

A = 1

B = 4

FOR I = 1 TO 16

PRINT A

C = A + B

PRINT C

A = B

B = C

NEXT I

END

**20. Write a program that accepts two integers and displays HCF of them**.

CLS

INPUT “ENTER ANY TWO NUMBERS”; A, B WHILE A MOD B <> 0

T = A MOD B

A = B

B = T

WEND

PRINT “H.C.F=”; B

END

**21. Write a program that accepts any ten numbers and displays the smallest number among them.**

CLS

INPUT “ENTER FIRST NUMBER”; N

FOR I = 2 TO 10

INPUT “ENTER NEXT NUMBER”; S

IF S<N THEN N = S

NEXT I

PRINT “THE SMALLEST NUMBER IS “; N

END

**22. Write a program that accepts any ten numbers and displays the greatest number among them**.

CLS

INPUT “ENTER FIRST NUMBER”; N

FOR I = 2 TO 10

INPUT “ENTER NEXT NUMBER”; G

IF GN THEN N = G

NEXT I

PRINT “THE GREATEST NUMBER IS “; N

END

**23. Write a program that accepts a number and displays the factorial of the number.[Hint: Factorial of 4 is 4 * 3 * 2 * 1 i.e. 24]**

CLS

INPUT”ENTER A NUMBER”;N

F=1

FOR I = 1 TO N

F = F * 1

NEXT I

PRINT “THE FACTORIAL=”;F

END

**24. Write a program that asks a user to input an integer number. The program counts and displays the total number of factors of the number.**

INPUT “Ender a number “; N

FOR I = 1 TO N

If N MOD I = 0 THEN

F = F + 1

NEXT I

PRINT “TOTAL NUMBER OF FACTOR IS”; F

END

**25. Write a program that asks a user to input an integer and displays sum of the factors of the numbers.**

CLS

INPUT “ENTER ANY NUMBER”; N

S = 0

FOR I = 1 TO N

IF N MODI = 0 THEN = s + 1

NEXT I

PRINT “SUM OF FACTORS=”; S

END

**26. Write a program that accepts an integer and check whether the number is perfect number or not. [Hint: A perfect number is the number whose sum of the factors (excluding number itself) is equal to number itself. E.g. 6 is perfect number, since the sum of the factors of 6 (excluding 6) is 1+2+3 i.e. 6]**

CLS

INPUT “ENTER ANY NUMBER”; N

S=0

FOR I= 1 TO N-1

IF N MODI = 0 THEN S=S+I

NEXT I

IFS=N THEN

PRINT “PERFECT NUMBER”

ELSE

PRINT “NOT PERFECT NUMBER”

END IF

END

**27. Write a program that accepts an integer number and checks whether the number is prime or composite.**

CLS

INPUT “ENTER ANY NUMBER”; N

A = 0

FOR I = 1 TO N

IF N MOD I = 0 THEN A = A + 1

NEXT I

IF A = 2 THEN

PRINT “IT IS PRIME NUMBER”;

ELSE

PRINT “IT IS NOT PRIME NUMBER”;

END IF

END

**28. Write a program that accepts a multi-digit integer number and displays sum of it digits**.

CLS

INPUT “ENTER ANY NUMBER”; N

S = 0

WHILE N <> 0

RN MOD 10

S=S+R

N = N \ 10

WEND

PRINT “SUM OF DIGITS”; S

END

**29. Write a program that accepts a multi digit integer number and displays sum of even digits of the number.**

CLS

INPUT “ENTER ANY NUMBER”; N

S = 0

WHILE N <>0

RN MOD 10

IFR MOD 2 = 0 THEN S=S+R

N = N \ 10

WEND

PRINT “SUM OF EVEN DIGITS”; S

END

**30. Write a program that accepts a multi digit integer number and displays the product of the digits of the number.**

CLS

INPUT “ENTER ANY NUMBER”; N

P = 1

WHILE N <>0

R = N MOD 10

P=PR

N = N \ 10

WEND

PRINT “PRODUCT OF DIGITS”; P

END

**31. Write a program that accepts an integer number and displays the reverse of the number. [Hint: if an integer is 457 then the reverse is 754.]**

CLS

INPUT “ENTER ANY NUMBER”; N

S=0

WHILE N <> 0

RN MOD 10

S=S10+R

N=N\ 10

WEND

PRINT “REVERSED DIGITS=”; S

END

**32. Write a program that accepts an integer number and checks whether the number is palindrome or not.**

CLS

INPUT “ENTER ANY NUMBER”; N

A = N

S = 0

WHILE N <> 0

R = N MOD 10

S = S * 10 + R

N = N \ 10

WEND

IF A = S THEN

PRINT A; “IS PALINDROME”

ELSE

PRINT A; “IS NOT PALINDROME”

END IF

END

**33. Write a program that accepts an integer number and displays the sum of odd digits of the number.**

CLS

INPUT “ENTER ANY NUMBER”; N

S=0

WHILE N <>0

R = N MOD 10

IF R MOD 2 = 1 THEN SS+R

N = N \ 10

WEND

PRINT “SUM OF ODD DIGITS”; S

END

**34. Write a program that asks a user to input a three digit integer and checks whether 10 the number is Armstrong or not.**

CLS

INPUT “ENTER ANY NUMBER”; N

A = N

S = 0

WHILE N <>0

R = N MOD 10

S = S + R^3

N = N \ 10

WEND

IF A = S THEN

PRINT A; “IS ARMSTRONG”

ELSE

PRINT A; “IS NOT ARMSTRONG”

END IF

END

### 35. Write programs to display the following numeric patterns:

**a. **1 2 3 4 5

1 2 3 4

1 2 3

1 2

1

CLS

FOR i = 5 TO 1 STEP -1

FOR j = 1 TO i

PRINT j;

NEXT j

PRINT

NEXT i

END

**b.** 1

1 2

1 2 3

1 2 3 4

1 2 3 4 5

CLS

FOR i = 1 TO 5

FOR j = 1 TO i

PRINT j;

NEXT j

PRINT

NEXT i

END

**c.** 5 4 3 2 1

5 4 3 2

5 4 3

5 4

5

CLS

FOR i = 1 TO 5

FOR j = 5 TO i STEP -1

PRINT j;

NEXT

PRINT

NEXT

END

**d. **5 4 3 2 1

4 321

321

21

1

CLS

FOR i = 5 TO 1 STEP -1

FOR j = i TO 1 STEP -1

PRINT j;

NEXT j

PRINT

NEXT i

END

**e. **1 2 3 4 5

2 3 4 5

3 4 5

4 5

5

CLS

FOR i = 1 TO 5

FOR j = i TO 5

PRINT j;

NEXT j

PRINT

NEXT i

END

**f. **5

4 5

3 4 5

2 3 4 5

1 2 3 4 5

CLS

FOR i = 5 TO 1 STEP -1

FOR j = i TO 5

PRINT j;

NEXT j

PRINT

NEXT i

END

**g.** 1

2 2

3 3 3

4 4 4 4

5 5 5 5 5

CLS

FOR i = 1 TO 5

FOR j = 1 TO i

PRINT i;

NEXT j

PRINT

NEXT i

END

**h. **5 5 5 5 5

4 4 4 4

3 3 3

2 2

1

CLS

FOR i = 5 TO 1 STEP -1

FOR j = 1 TO i

PRINT i;

NEXT j

PRINT

NEXT i

END

If Class 10 Review Of Control Statement Notes were helpful to you then don’t forget to share this notes with your friends & classmates.

### Discover more from WebNotee

Subscribe to get the latest posts sent to your email.