wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Pseudo Code

Total questions: 10

Worksheet time: 30mins

Name
Class
Date
1.

What will be the output of the following Pseudo code?


int p=4, q=7, r=10

p=q mod r

q=q+p

r=r+q

print p, q and r

a)

7 14 24

b)

7 11 17

c)

7 14 21

d)

4 11 17

2.

What will be the output of the following algorithm for Num = 10?

Start

Declare variable I, J and Num

Enter Value of Num

Repeat for I=1 to Num

Declare static variable sap and Set sap=0

sap=sap+I

J=sap

end loop

Print j

Stop

a)

85

b)

55

c)

75

d)

65

3.

Predict the output of the following pseudo code?


integer a = 2, b = 50;

a=a+b;

b=a-b;

print a;

print b;

a)

2 52

b)

2 50

c)

52 2

d)

52 48

4.

const char* p = "12345";

const char **q = &p;

*q = "abcde";

const char *s = ++p;


What will be the vale of *++s?

a)

abc

b)

bcd

c)

cde

d)

de

5.

a[][3] = {1, 2, 3, 4, 5, 6}

(*ptr)[3] = a

print (*ptr)[1], (*ptr)[2])

++ptr

print (*ptr)[1], (*ptr)[2])


What is printed as the output?

a)

2 3 5 6

b)

2 3 4 5

c)

4 5 0 0

d)

4 5 8 6

6.

a=1;

b=1;

while(a<=500)

begin

a=2^a;

b=b+1;

end

What is the value of b at the end of the Pseudo code?

Note: ^ read it as 2 to the power of a

a)

7

b)

5

c)

4

d)

6

7.

How many times will the following loop get executed?


for x = 5 to 1

for y = 1 to x

print y

a)

11

b)

15

c)

12

d)

14

8.

What does the following fragment print?


c[] = "CAPG2019"

*p =c

print p + p[3] - p[1])

a)

CAPG2019

b)

2019

c)

019

d)

19

9.

a[5] = {1,2,3,4,5};

*ptr = (int*)(&a+1);

print *(a+1), *(ptr-1));


What is printed when implementing the above pseudo-code?

a)

2 5

b)

5 2

c)

1 3

d)

3 1

10.

Declare integer i and pointer *ptr.

Dynamically allocate memory for pointer for 5 integers.


For i = 0 to 4

Assign i to *(ptr+i);

Print *ptr++, (*ptr)++, *ptr, *++ptr and ++*ptr;


What will the output?

a)

0 1 2 2 3

b)

0 1 2 3 4

c)

1 2 3 4 5

d)

Garbage Value