Algorithmic
Problem Solving
Composition
and Decomposition
Evaluation
Part I
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
(c)
u, v = 10 ,5
(b)
u, v = 5 ,10
(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 := i+1, j-1
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 C1
2 S1
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 S1
2 while C
3
S2
4 S3
(a) S1 ; S3
(b)
S1 ; S2 ; S3
(c)
S1 ; S2 ; S2 ; S3
(d)
S1 ; 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.
How many times the loop is iterated?
i := 0
while i ≠ 5
i := i + 1
(a)
4
(b) 5
(c)
6
(d)
0
Related Topics
Privacy Policy, Terms and Conditions, DMCA Policy and Compliant
Copyright © 2018-2023 BrainKart.com; All Rights Reserved. Developed by Therithal info, Chennai.