You are on page 1of 9

1.

Trace the following flowchart for input 11

Start
Input N

I=1

When
I<=N

Output I

I = I+ 2

End

2. Trace the following flowchart for input 20

Start
Input N

I=1

When
I>N

Yes

No
IF I%3
=0

Yes

No
IF I%5
=0

No

I = I+ 1

End

Yes
Output I
Output I*(1)

3. Trace the following flowchart for input 21

Start
Input N

F=0
F1 = 1

When
F<=N

Output F
Ftemp=F
F = F1
F1 = F1+Ftemp

End

4. Trace the following flowchart for input 20

Start
Input N

I=2
Sum = 0

When
I<=N

Sum = Sum + I
I = I+ 2

End

Output
Sum

5. Trace the flowchart for the following inputs:


a. 0
b. 2
c. 31

Start
Read age
old=1, year=3

age%year =0

Yes

old=0

No

year=year
+1

Yes

year < age

No

Print age, is
young age

Print age, is
old age
End

6. Trace the following flowchart for input 56096

Start
nput
NumerGet num

d = num % 10

num = num d

No

num > 0?
Yes

Stop

num = num / 10
Display d

7. Trace the following flowchart for the given input.


Start

Read I

Read J

No

If I > 0
Yes
If J > 0

Yes
Print I*J

Stop
Input I = 3;
Input J = 5;

J = j-1

NO
I = I-1

8. Trace the following flowchart for the given input


Start
Set J = 0,
D=0
Input S

Input P

D = S % 10
P=P-1
S = S / 10

Yes

If P >
1
No
J = 2*D

Print J

D=D-1
Yes

If
D>1
No

Input S = 41237
Input P = 2
[N.B Here (%) means Mod. Ex. = 11%10 = 1]

Stop

9. Trace the following flowchart for input n=20 & 53, 52


Start

C=0
P=0
R=0
Read n

T=n % 2

C=C+1
n=n/2

T=0
F
T=n % 2
n=n/2
p=10*p+T

n>0

F
T=p % 10
p=p/10
r=10*r+T
T

p>0
F
C>0

Print r

T
r=r*10
C=C-1

End

You might also like