0% found this document useful (0 votes)
8 views

Pseudo-code Revision Sheet-1-Practice

Pseudo code

Uploaded by

carhub4411
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

Pseudo-code Revision Sheet-1-Practice

Pseudo code

Uploaded by

carhub4411
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

Extra Set-3

1. What will be the output of the following pseudocode?

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

2. what will be the output of the following pseudocode for input 7?

1. Read the value of N.


2. Set m = 1, T = 0
3. if m > n
4. Go to line no. 9
5. else
6. T=T+m
7. m=m+1
8. Go to line no. 3
9. Display the value of T
10. Stop

a) 32
b) 76
c) 56
d) 28
3. What will be the output of the following pseudocode if we call fun(2) ?

1. int fun (int n)


2. if (n EQUALS 4)
3. return n
4. else
5. return 2 * fun (n + 1)

a) 2
b) 4
c) 8
d) 16

4. What will be the output of the following code ?


main()
{
int i,j;
for(i=0;i<=4;i++)
{
for(j=0;j<=3;j++)
{
printf ("%d ",j++);
break;
}
if(i%2==0)
continue;
printf("%d %d ",i,j);
}
}

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

5. What will be the output of the following pseudo code ?

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

6. How many times will the print statement be executed?

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

7. What will be the output of the following pseudo code ?

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

9. What will be the output of the following pseudocode?

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

12. What will be the output of the following pseudocode?

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

15. What will be the output of the following pseudocode?

Integer a[3][3], k , j, sum


Set sum = 0
Set a[3][3] = {{1,2,3}, {4,5,6}, {7,8,9}}
for each k from 0 to 2:
for each j from 0 to 2:
sum = sum + a[k][j]
end for
jump out of the loop
end for
print sum

a) 55
b) 45
c) 6
d) None of these

16. What will be the output of the following pseudocode?

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 ?

1. Print ( a > 45 OR b > 50 AND c > 10 )


2. Print ( ( a > 45 OR b > 50 ) AND c > 10 )

a) 0 and 0
b) 0 and 1
c) 1 and 0
d) 1 and 1

18. What will be the output of the following pseudocode?

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

20. What will be the output of the following pseudocode?

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

21. What will be the output of the following pseudocode?

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

23. What will be the output of the following pseudocode?

Integer x = 10
x &= ~2
Print x

a) 10
b) 8
c) 12
d) 0

24. What will be the output of the following pseudocode?


Integer a[6], p, j, q
Set p = 3
Set a[6] = {3,6,10,12,23,33}
for (each j from 0 to 5)
if((a[j] MOD p) EQUALS 0)
p =a[j] - (p*3)
end if
q = p + a[j] - 3
end for
print q

a) 51
b) 52
c) 53
d) 54

25. What would the program print?


Double pi = 3.141
Integer a = 1
Integer i
for each i 0 to 2:
If a = cos(pi * i/2)
Print "1"
Else
Print "0"

A)000
B)010
C)101
D)111

26. What will be the output of the given code?

char X[10]={'A'},i;

for(i=0; i<10; 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

27. What will be the output of the following code?


int main()
{
int val=0;
char str[]="ABC";
val=strcmp(str,"ABC");
printf("%d",val);
return 0;
}
A) 0
B) 1
C) -1
D) None of these
28. What will be the output of the code?
main()
{
char str[]="value is =%d";
int a='7';
str[11]='c';

printf(str,a);
}

A) value is ='7'
B) value is = 54
C) Error
D) value is =7

29. What will be the output of the following code?

if (printf("Hello") == strlen("Hello"))
printf("...Friends");
else
printf("...Enemies");
return 0;

A) Hello...Friends
B) ...Friends
C) Hello...Enemies
D) Enemies

30. Find output of the following code:

PROCEDURE fun ( int n, int *fp )


Begin:
if ( n <= 1 )
{
*fp = 1;
return 1;
}
int t = fun ( n-1, fp );
int f = t + *fp;
*fp = t;
return f;
End Fun
PROCEDURE main() :
Begin:
int x = 15;
printf("%d",fun(4, &x));
End main

a) 8
b) 7
c) 6
d) 5

You might also like