Pseudo-code Revision Sheet-1-Practice
Pseudo-code Revision Sheet-1-Practice
Integer a, b, c, d
Set b = 18, c = 12
a=b–c
for (each c from 1 to a – 1)
b = b + c + 12
b = b/5
d=b+a
end for
c=a+b+c
Print a b c
a) 539
b) 6 4 14
c) 6 4 16
d) 6 14 17
a) 32
b) 76
c) 56
d) 28
3. What will be the output of the following pseudocode if we call fun(2) ?
a) 2
b) 4
c) 8
d) 16
A. 0 0 1 1 0 0 3 1
B. 0 0 1 1 0 0 3 1 0
C. 0 0 1 0 0 2 1 0 0 4 1
D. 0 0 1 0 0 0 3 0 0
Integer c, d
Set c = 15, d = 12
d=c–1
X:
Print c
d=d+1
c = d + (c – 2)
if(c < 40)
Goto X
end if
A) 14 26 38
B) 27 39
C) 15 27 39
D) 15 26 36
1. Integer a, b, c
2. Set a = 8, b = 10, c = 6
3. if(a > c AND (b + c) > a)
4. Print a
5. end if
6. if(c > b OR (a + c) > b)
7. Print b
8. end if
9. if ((b + c) MOD a EQUALS 0)
10. Print c
11. end if
a) 0
b) 1
c) 2
d) 3
1. Integer x, y, z
2. Set x = 24, y = 8
3. x = x / y
4. z = y << x
5. Print z
a) 1
b) 8
c) 32
d) 64
8. What will be the output of the following pseudocode if a = 10 and b = 6, c=?
1. Integer func (Integer a, Integer b)
2. Integer temp
3. while (b)
4. temp = a MOD b
5. a=b
6. b = temp
7. end while
8. return a
9. End function func()
a) 1
b) 2
c) 3
d) 4
void reverse(int n)
{
if (n > 5)
exit(0);
printf("%d ", n);
return reverse(n++);
}
int main()
{
reverse(1);
}
a) Segmenation fault
b) Compilation error
c) Print 1 Infinitetime
d)Both a & c
10. What will be the output of the following pseudocode for fun("pqr") ?
fun(char *a)
if (*a EQUALS NULL)
return
end if
fun(a+1)
fun(a+1)
print *a
a) ppqqrr
b) rrqrqqp
c) rrqrrqp
d) rqppqr
11. What will be the output of the following pseudocode for fun(99)?
1. Integer fun(Integr n)
2. if (n > 100)
3. return n - 10
4. return fun(fun(n+11))
5. end function fun()
a) 91
b) 100
c) 110
d) 121
1. Integer a = 10
2. Integer b = 2
3. Integer c
4. c=(a & b)
5. Print c
a) 0
b) 2
c) 10
d) 12
13. What will be the output of the following pseudocode?
Integer a, b, c
Set b = 2, c = 4
for (each a from 1 to 4)
b = b >> 1
c = c << b
end for
Print b+c
a) 2
b) 4
c) 1
d) 8
14. Given the following pseudocode for function printx() below, how many
times
is x printed if we execute printx(5)?
void printx(int n)
{
if (n==0)
{
printf("x");
}
for (int i=0;i<=n-1;++i)
{
printx(n-1);
}
}
A) 625
B) 256
C) 120
D) 24
E) 5
a) 55
b) 45
c) 6
d) None of these
1. Integer a = 0 , b = 1 , c = 2
2. b=( ( a+1==1) ? a&b : c&a) ? b : c;
3. Print a , b, c
a) 0 1 2
b) 0 2 0
c) 0 2 2
d) 0 0 2
17. What will be the output of the following pseudocode if a=10, b=60 ,c=20 ?
a) 0 and 0
b) 0 and 1
c) 1 and 0
d) 1 and 1
1. Integer num = 8
2. Print num<<1, num>>1
a) 8 0
b) 0 0
c) 16 4
d) 16 0
19. What will be the output of the following pseudocode?
1. Integer i = 16
2. i = !i > 15
3. Print i
a) i = -1
b) i = 0
c) i = 1
d) i = 2
1. Integer i = 5, j = 4
2. if(!print(“”))
3. Print i, j
4. else
5. Print i++, ++j
a) 5 5
b) 5 4
c) 5 6
d) 6 6
Character var=0x04
var = var | 0x04
Print var
var |= 0x01
Print var
a) 8, 9
b) 4, 5
c) 8, 8
d) 4, 4
22. What will be the output of the following pseudocode?
Character flag=0x0f
flag &= ~0x02
Print flag
a) 13
b) d
c) 22
d) 10
Integer x = 10
x &= ~2
Print x
a) 10
b) 8
c) 12
d) 0
a) 51
b) 52
c) 53
d) 54
A)000
B)010
C)101
D)111
char X[10]={'A'},i;
printf("%d ",X[i]);
A) 65 0 0 0 0 0 0 0 0 0 0
B) A \0 \0 \0 \0 \0 \0 \0 \0 \0
C) 65 Garbage ( nine times)
D) None of these
printf(str,a);
}
A) value is ='7'
B) value is = 54
C) Error
D) value is =7
if (printf("Hello") == strlen("Hello"))
printf("...Friends");
else
printf("...Enemies");
return 0;
A) Hello...Friends
B) ...Friends
C) Hello...Enemies
D) Enemies
a) 8
b) 7
c) 6
d) 5