Vous êtes sur la page 1sur 9

1.

Trace the following flowchart for input 11

Start

Input N

I=1

When No
I<=N

Yes
Output I

I = I+ 2

End
2. Trace the following flowchart for input 20

Start

Input N

I=1

When Yes
I>N

No

IF I/3 Yes
=0
No
IF I/5
Yes
=0
No Output I
Output I*(-
1)

I = I+ 1

End
K
3. Trace the following flowchart for input 21

Start

Input N

A = 0 , B = 1, C = 1

No
When
C<=N
Yes
Output C

C = A+ B
A=B
B=C

End
4. Trace the following flowchart for input 20

Start

Input N

I=2
Sum = 0

No
When
I<=N

Yes
Sum = Sum + I Output
I = I+ 2 Sum

End
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
Yes year < age
+1
Print age, “is
young age”
No

Print age, “is


old age”

End
6. Trace the following flowchart for input 56096

Start

Prompt 摘 nter a
number�Input 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

NO
If J > 0 I = I-1

Yes
Print I*J

J = J-1
Stop

Input I = 3;
Input J = 5;
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
If
Yes D>1
No
Input S = 41237
Input P = 2 Stop

[N.B Here (%) means Mod. Ex. = 11%10 = 1]


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 T T=0
n=n/2
F
T=n % 2
n=n/2
P=10*P+T

T
n>0

F
T=P % 10
P=P/10
R=10*R+T

T
P>0

C>0 F Print R

T
R=R*10 End
C=C-1

Vous aimerez peut-être aussi