" /> -->

#### Composition and Decomposition Book Back Questions

11th Standard

Reg.No. :
•
•
•
•
•
•

Computer Science

Time : 00:45:00 Hrs
Total Marks : 30
5 x 1 = 5
1. Suppose u, v = 10, 5 before the assignment. What are the values of u and v after the sequence of assignments?
1 u :=v
2 v := u

(a)

u, v = 5,5

(b)

u, v = 5 ,10

(c)

u, v = 10,5

(d)

u, v = 10 ,10

2. Which of the following properties is true after the assignment (at line 3)?
1 -- i+j = 0
2 i, j := i1+, j1-
3 -- ?

(a)

i + j > 0

(b)

i+j < 0

(c)

i+j=0

(d)

i = j

3. If C1 is false and C2 is true, the compound statement
1 if CI
2 SI
3 else
4 if C2
5 S2
6 else
7 S3
executes

(a)

S1

(b)

S2

(c)

S3

(d)

none

4. If C is false just before the loop, the control flows through
1 SI
2 while C
3 S2
4 S3

(a)

S1 ; S3

(b)

S 1 ; S2 ; S3

(c)

S 1 ; S2 ; S2 ; S3

(d)

S 1 ; S2 ; S2 ; S2 ; S3

5. If C is true, S1 is executed in both the flowcharts, but S2 is executed in

(a)

(1) only

(b)

(2) only

(c)

both (1) and (2)

(d)

neither (1) nor (2)

6. 3 x 2 = 6
7. Distinguish between a condition and a statement.

8. Why is function an abstraction?

9. How do we refine a statement?

10. 3 x 3 = 9
11. If C is false in line 2, trace the control flow in this algorithm.
1 S1
2 -- C is false
3 if C
4 S2
5 else
6 S3
7 S4

12. Define a function to double a number in two different ways:
(1) n + n,
(2) 2 x n.

13. For the given two flowcharts write the pseudo code

14. 2 x 5 = 10
15. Exchange the contents: Given two glasses marked A and B. Glass A is full of apple drink and glass B is full of grape drink. Write the specification for exchanging the contents of glasses A and B, and write a sequence of assignments to satisfy the specification.

16. Trace the step-by-step execution of the algorithm for factorial(4). factorial(n)
--inputs: n is an integer, n > 0
-- outputs: f = n!
f, i := 1 ,1 while i < n
f, i := f X i, i1+