0% found this document useful (0 votes)
6 views80 pages

Pseudo Code

The document contains a series of programming questions and their potential outputs based on given pseudocode or algorithms. Each question presents a scenario involving variables, functions, loops, and conditions, asking for the expected result or behavior. The questions cover various programming concepts, including sorting, searching, recursion, and data structures.

Uploaded by

shaikfarhin1236
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)
6 views80 pages

Pseudo Code

The document contains a series of programming questions and their potential outputs based on given pseudocode or algorithms. Each question presents a scenario involving variables, functions, loops, and conditions, asking for the expected result or behavior. The questions cover various programming concepts, including sorting, searching, recursion, and data structures.

Uploaded by

shaikfarhin1236
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

1

What will be the value of s if n=127?

Read n

i=0,s=0

Function Sample(int n)

while(n>0)

r=n%l0

p=8^i

s=s+p*r

i++

n=n/10

End While

Return s;

End Function

120

187

87

27

2
Read N

Function sample(N)

s = 0, f = 1, i=1;

Do Until i <= N

f = f * i;

s = s +(i / f);

i=i+1

End Do
return(s);

End Function

716667

708333

Infinite Loop

666667

3
What will be the output if limit = 6?

Read limit

n1 = 0, n2= 1, n3=1, count = 1;

while count <= limit

count=count+1

print n3

n3 = n1 + n2

n1 = n2

n2 = n3

End While

123581321

12358132

12358

112358
4
What will be the value of even_counter if number = 2630?

Read number

Function divisible(number)

even_counter = 0, num_remainder = number;

while (num_remainder)

digit = num_remainder % 10;

if digit != 0 AND number % digit == 0

even_counter= even_counter+1

End If

num_remainder= num_remainder / 10;

End While

return even_counter;

5
What will be the value of t if a = 56 , b = 876?

Read a,b

Function mul(a, b)

t=0

while (b != 0)

t=t+a

b=b-1

End While
return t;

End Function

None of the mentioned above

49056

490563

490561

6
Code to sort given array in ascending order:

Read size

Read a[1],a[2],…a[size]

i=0

While(i<size)

j=i+1

While(j<size)

If a[i] < a[j] then

t= a[i];

a[i] = a[j];

a[j] = t;

End If

j=j+1

End While

i=i+1

End While

i=0

While (i<size)
print a[i]

i=i+1

End While

Line 4

No error

Line 7

Line 6

7
What is the time complexity of searching for an element in a circular linked list?

None of the mentioned

O(1)

O(nlogn)

O(n)

8
In the worst case, the number of comparisons needed to search a singly linked list of length n for a given element is

n⁄2

log 2 n – 1
log 2 n

9
Which of the following will give the best performance?

O(n!)

O(n^C)

O(n log n)

O(n)

10
How will you find the minimum element in a binary search tree?

a) public void min (Tree root)

while ([Link] () != null)

root = [Link] ();

[Link] ([Link] ());

b) public void min (Tree root)

while (root != null)

root = [Link] ();

[Link] ([Link] ());

c) public void min (Tree root)

while ([Link] () != null)


{

root = [Link] ();

[Link] ([Link] ());

d) public void min (Tree root)

while (root != null)

root = [Link] ();

[Link] ([Link] ());

11
How many times the following loop be executed?

ch = ‘b’;

while(ch >= ‘a’ && ch <= ‘z’)

ch++;
}

26

25

12
Consider the following piece of code. What will be the space required for this code?

int sum (int A[], int n)

int sum = 0, i;

for (i = 0; i < n; i++)

sum = sum + A[i];

return sum;

}// sizeof(int) = 2 bytes

2n+8

2n+2

2n+4

2n

13
What will be the output of the following pseudo code?

For input a = 8 & b = 9.

function (input a, input b)

If (a < b)
return function (b, a)

elseif (b != 0)

return (a + function (a, b - 1))

else

return 0

72

65

88

56

14
What will be the output of the following pseudo code?

Input m = 9, n = 6 ,

m = m + 1 ;

N = n - 1 ;

m = m + n

if (m > n)

print m

else

print n

15

10

6
15
What will be the output of the following pseudo-code?

Input f = 6, g = 9 and set sum = 0

Integer n if (g > f)

for (n = f; n < g; n = n + 1)

sum = sum + n

End for loop

else

print error message print sum

15

21

16
Consider a hash table with 9 slots. The hash function is h(k) = k mod 9. The collisions are resolved by chaining. The

following 9 keys are inserted in the order: 5, 28, 19, 15, 20, 33, 12, 17, 10. The maximum, minimum, and average chain

lengths in the hash table, respectively, are

3, 0, and 1

3, 0, and 2

4, 0, and 1

3, 3, and 3

17
You have an array of n elements. Suppose you implement a quick sort by always choosing the central element of the array
as the pivot. Then the tightest upper bound for the worst case performance is:

O(n3)

Θ(nLog2)

O(nLogn)

O(n2)

18
Let G be a graph with n vertices and m edges. What is the tightest upper bound on the running time on Depth First Search

of G? Assume that the graph is represented using adjacency matrix.

O(n2)

O(mn)

O(m+n)

O(n)

19
Let P be a Quick Sort Program to sort numbers in ascending order using the first element as a pivot. Let t1 and t2 be the

number of comparisons made by P for the inputs {1, 2, 3, 4, 5} and {4, 1, 5, 3, 2} respectively. Which one of the

following holds?

t1 = t2

t1 > t2

t1 < t2
t1 = 5

20
What does the following piece of code do?

public void func (Tree root)

func ([Link] ());

func ([Link] ());

[Link] ([Link] ());

Level order traversal

Post order traversal

Inorder traversal

Preorder traversal

21
below is a pseudocode

Set x to 0;

Set n to 1;

while (n <= 100)

x = x + n;

n = n + 1;

end write x
What is the output of the above pseudocode?

5151

100

4950

5050

22
Below is a pseudo-code

Set x to 1;

Set x1 to 0;

Set x2 to 0;

Set x3 to 1;

While (x & lt;

10)

Set x1 = x1 + x2 + x3;

Set x2 = x2 + x1 + x3;

Set x3 = x3 + x2 + x1;

Write x1;

write x2;

write x3;

x = x + 1;

In which series is the output

Arithmetic series

Triangular series
Fibonacci series

Tribonacci series

23
What will be the output of the following pseudocode?

Integer a,b,c

Set a=6,b=84

while(b>0)

b=b/2

a=a+6

c=a+b

while(c>40)

if(c mod 2 IS EQUAL TO 0)

Print a

else

Print b

c=c/10

End while

End while

Print c
12 , 4

12, 1, 48, 4

12,1,4

48, 4

24
What will be the output of the following pseudocode for i=140?

Integer fun(integer i)

if((i MOD 2) NOT EQUALS 0)

Return i

Else

Return fun(fun(i-1))

End function fun()

None of the mentioned options

138

140

139

25
Consider the following the given algorithm and identify the task performed by this

bstree(*tree)

while((tree->left !=null)&&(tree->right !=null))

if(tree-> root)
bstree(tree->left);

else

return (1);

if(tree->right > tree->root)

bstree(tree->right);

else

return (1);

return (0);

None of the mentioned options.

Tests whether a binary tree is a Binary Search Tree

Prim’s algorithm

Bubble sort

26
What will be the output of the following pseudocode?

Integer a,b

Set a=2, b=50

while(b>0)

a = b MOD 2 +a

if( a MOD 3 IS EQUAL TO 0)

Print (a)

else

Print(b-1)

b=b/5

a=a+1

end while
3,3,3

50,3,2

50,10,2

49,3,1

27
What will be the output of the following pseudocode?

Integer a, b, c, d, e

Set a=50 , b=3, c=3

while(c>0)

d=a mod b

e= e + d + a

c= c - 1

End while

Print e

153

156

100

52

28
What will be the output of the following pseudocode?

Integer array1[10] = {2, 3, 56, 34}

Integer k, a, j, n

Set a = 3, n = 4

for(each k from 0 to n-1)


Set array1[n] = array1[0]

for(each j from 0 to n-1)

Set array1[j] = array1[j+1]

End for

End for

for(each k from 0 to n-1)

Print array1[k]

End for

2 3 34 56

None of the mentioned options

34 2 3 56

56 34 3 2

29
What will be the output of the following pseudocode?

Integer j,i,count,num

Set j=31, count=0, num=64

while(num NOT EQUALS 0)

if((num&1) is EQUAL to 1)

Jump out of the loop

else

count=count+1

num = num>>1

End while

Print count

5
12

95

30
What will be the output of the following pseudocode for a given set of input?

integer a

if((a mod 10) IS EQUAL TO 0)

a=a*2

else if((a mod 5 ) IS EQUAL TO 0)

a=a/5

else

a=a-1

end if

input : a=25, a=16

a=35,a=25

a=25,a=15

a=15,a=20

a=5,a=15

31
What will be the output of the pseudocode?

Integer x, y, z

Set x=10,y=12,z=12

z=(x+y)/4

if(z IS EQUAL TO 12)

Print successful
Else

Print unsuccessful

None of the above

Error

unsuccessful

successful

32
What will be the output of following pseudocode?

Integer a,b,count,count1

Set a=1, b=1

while(a<=5)

b=1

while(b<=5)

b=b+1

count1 = count1 + 1

end while

a= a + 1

count = count +1

End while

Print count, count1

count=50 count1=25

count=50 count1=5

count=45 count1=25
count=5 count1=25

33
what will be the output

#include<stdio.h>

int main()

int number = 10, expo = 2,temp = 1;

while (expo is not equals to 0)

temp = temp * number;

--expo;

printf("%d, %d",number, temp);

return 0;

Error

None of the above

100, 10

10,100

34
What will be the output of following pseudo code?

Integer i,j,sum,n

Set sum=0,n=7

Repeat for i=1to n

sum=sum +(i*i)

End loop

Print sum
160

140

120

100

35
What will be the output of the following:

Integer a,b,c

Set a=10,b=20

for(c=a;c<=b;c=c+2)

a=a+c

b=b-a+c

if(a>10)

Print a

else

Print b

End if

End for

40

30

20

10
36
What will be the output of the following c code?

#include

int main()

int a = 45;

int i=sizeof(a);

printf("%d",i);

37
what will be output of following c code?

#include<stdio.h>

int f(int n)

static int a =0;

if(n<=0)

return 1;

if(n>3)

a=n;

return f(n-2) +2;


}

return f(n-1) + a;

int main()

printf("Result: %d",f(5));

return 0;

18

19

38
What will be the output of the following pseudo-code for input 7?

Read the value of N.

Set m=1,T=0

If m >N

Go to line No. 9

Else

T= T+m

m=m+1
Go to line no.3

Display the value of T

Stop

56

76

32

28

39
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

85

65

75
55

40
Consider the following pseudocode.

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 pseudocode?

41
What will be the output of the following pseudocode?

integer a, b, c;

Set a = 3;

b = 5;

c = 1;
a = a + b + c - 8;

b = a + c - 8;

if (a > b)

Print fine

else

Printf Thank you

None of these

Error

Thank you

Fine

42
What will be the output of the following pseudocode if n=5 and element of the array are 24,20,60,100,200?

#include <stdio.h>

integer

fun (int a[], int n)

integer x;

if (n is equal to 1)

return a[0];

else
x = fun (a, n - 1);

if (x == a[n - 1])

return x;

else

return a[n - 1];

End the function fun ()

400

300

200

100

43
What will be the output of the following pseudocode?

integer a = 1, b = 2;

for (int i = 0; i <= 6; i = i + 2)

a = a + b + i;

a = a + b;

b = a - b;
Print b End for

13 10 47 70

13 10 27 70

3 10 27 70

30 10 27 70

44
What will be the output of the following code :

Integer a, b, c, v;

Set a = 5;

b = 6;

v = 90;

while (v > 8)

a = a + v;

c = (a + b) % 10;

while (c > 9)

b = b - a;

c = c - 1;
End while

v = v/2

End while

Print b, c

35

17

57

69

45
What will be the output of the following code ?

for (i = 1; i <= 6; i++)

for (j = i; j < 6; j++)

Print blank space

for (k = 1; k < (i * 2); k++)

Print *

End for

Line break
End for

None of the above

* ** *** **** *****

Error

* *** ***** ******* ********* ***********

46
What will be the output of the following pseudocode?

integer a, b, c;

Set a = 6;

b = 84;

while (b > 0)

b = b / 2;

a = a + 6;

c = a + b;

while (c > 40)

if (c mode 2 is equal to 0)

Print a
else

Print b c = c / 10;

End while Print c

12 1 4 48

10 12 4 48

1 12 48 4

12 1 48 4

47
what will be the output of the following pseudocode?

Integer n, rev, rem, orig;

Set n=63206; rev=0;

Set orig=n;

Repeat while n Not Equals 0

rem=n%10;

rev=rev*10+rem;

n=n/10;

End while
if(orig is Equal to rev)

Print rev

else

Print (orig-rev)/6

End if

105

495

110

120

48
What will be the output of the pseudocode?

Integer i,j,sum,n;

Set sum=0, n=7;

Repeat for i=1 to n

Repeat for j=1 to i

sum=sum+j

End loop
End loop

Print sum

75

90

84

80

49
For what value of a b and c the following pseudocode will execute both the print statements?

integer a,b,c;

set a = 5, b = 4, c = 7;

if(a>b OR a>c)

Print a

if(a+b>c AND b<c)

Print b

59

49

32
54

50
What will be the output of the following pseudocode?

integer a,b;

Set a=2; b=50;

while(b>0)

a = b%2 + a;

if( a MOD 2 Is Equal To 0)

Printf a

else

Print b-1

b = b/5

a=a+1

End while

254

294

458
123

51
What will be the output of the following pseudocode?

integer a, b, c, a1, b1, c1, a2, b2, c2;

Set a1 = 2 b1 = 45 c1 = 36;

Set a2 = 11 b2 = 26 c2 = 30;

c = c1 + c2;

b = c / 60;

c = c % 60;

b = b + b1 + b2;

a = b / 60;

b = b % 60;

a = a + a1 + a2;

Print a:b:c

20 : 22 : 26

14 : 12 : 6

10 : 15 : 60

5 : 10 : 15

52
What will be the output of the following pseudocode if n=40 and LIMIT=100?

Integer fun2(Integer n);

if(n <+ 0)

return 1;

if(n > LIMIT)

return 2;

Print ,n

fun2(2*n);
Print n

End function fun2()

80 120 120 80

40 80 80 40

20 40 40 20

10 20 20 10

53
For which of the following sets of input, the following pseudocode will print Q?

integer a=32,b=69,c=68;

if(a+c>b)

if(b<c)

printf("P");

else

printf("Q");

54
What will be the output of the following pseudocode for x=3 and y=4?

integer fun(int x, int y)

if(x>0)

fun(x-1,y+1);
End if

Print y

End function fun()

2034

5214

7654

8542

55
What will the output of the following pseudocode for i=140?

integer fun(int i)

if((i%2)!=0)

return i;

else

return fun(fun(i=1));

End function fun()

56
What will be the output of the following pseudo-code for a given array a[5]=3,4,6,1,2 and pos=2

[note: n= size of the array i.e. 5 and starting array index is 0]

Declare i,j,n,pos
Repeat for j=pos to n-1

Set a[j]=a[j+1] [end of loop]

n=n-1;

Display the new array

End

3615

324615

3415

34215

57
What will be the necessary condition to get the desired element from a given array by using the following algorithms?

If LOC = -1 do ITEM NOT FOUND

Do_Something(DATA, N, ITEM,LOC)

initialize Counter set LOC=0, LOW=0, HI= N-1

[Search for item]

Repeat while LOWs HI

MID = (LOW+HI)/2

IF ITEM = DATA[MID] do

LOC+MID

Return LOC

IF ITEM = DATA [MID}

HI = MID-1

ELSE

LOW = MID+1

No pre-condition is required for the algorithm to work


The elements is an array should be in the sorted form.

The array should contain more than one element

The elements should contain more than one element

58
What will be the output of the following C code?

#include<stdio.h>

int main()

int x = 2, y = 0, z = 3;

x>y ? printf(“%d”, z);;

59
What will be the output of the following C code?

Set a=3; b=5;c=1;

a=a+b+c-8;

b=a+c-8;

if(a>b)

Print fine

else

Printf Thank you


None of the mentioned

Error

Thank you

Fine

60
consider the following given code and predict its output.

main()

int num[ ]={1,4,8,12,16};

int *a,*b;

int i;

a=num;

b=num+2;

i=*a++;

printf("%d, %d, %dn",i,*a,*b);

4,4,8

2,1,8

4,1,8

1,4,8

61
What will be the output of the following code?

#include <iostream>

using namespace std;

int main()

{
int x=1,y=1;

for(;y;cout<<x<<y<<" ")

y=x++ <=5;

return 0;

21 31 41 51 61 70

21 31 51 61

22 23 44 55

31,71,41,60,21

62
What will be the output of the following code?

#include<stdio.h>

int main()

int i=1,j;

for(;;)

if(i)

j=--i;

if(j<5)

printf("Advance ",j++);

else

break;

return 0;
}

Compile-time error.

No, compile error but it’ll print Advance Four-time.

No, compile error but it will run into an infinite loop printing Advance.

No, compile error but it’ll print Advance Five-time

63
What will be the output of the following code?

#include<stdio.h>

int main()

int x=4,y=0;

int z;

z=(y++,y);

printf("%dn",z);

return 0;

compiler error

undefine behavior due to the order of evolution can be different

zero - '0'

64
What will be the output of the following code?

#include <stdio.h>
int f(int n)

static int a=0;

if(n<=0)

return 1;

if(n>3)

a=n;

return f(n-2)+2;

return f(n-1)+a;

int main()

printf("Result:%d",f(5));

return 0;

12

18

19

65
What will be the output of the following C code?

#include <stdio.h>

#define LIMIT 500


void fun2(int n)

if(n<=0)

return ;

if(n>LIMIT)

return ;

printf(" %d ",n);

fun2(2*n);

printf(" %d ",n);

int main()

fun2(17);

return 0;

17 34 68 136 272 272

17 34 68 136 272 272 136 68 34 17

17 34 68 136 272 272 136

17 34 68 136 272 272 136 68 34

66
What will be the output of the following C code?

#include <stdio.h>

int main()
{

int x=9,y=2,z=6;

int a=x&y|z;

printf("%d",a);

return 0;

Error

67
What will be the output of the following C code?

#include <stdio.h>

union Sti

int nu;

char m;

};

int main()

union Sti m;

printf("%d",sizeof(m));

return 0;

16
12

68
What will be the output for the pseudocode for x=11, y=57

fun(int x,int y)

if(x==0)

return y;

else

return fun(x-1 , x-y)

Zero (0)

None of these

69
What will be the output of the following algorithm?

#include<stdio.h>

int main()

int no=8125, temp, digit, sum = 0;

temp = no;

while (no > 0)

digit = no % 10;
sum = sum + digit;

no /= 10;

printf("%dn",sum);

return 0;

None of the above

17

16

15

70
What will be the output of the following C code

#include<stdio.h>

int main()

int x=2,y=0,z=3;

x>y ?( printf("%d", z)):( return z);

Error

Zero (0)

2
71
What will be the output of the following C code

#include<stdio.h>

int main()

char a='D';

printf(" %d",a);

return 0;

Error

69

68

67

72
What will be the output of the following C code

#include<stdio.h>

int main()

int a = 0,i = 0,b;

for(i=0;i<5;i++)

a++;

if(i == 3)

printf("Hello world");

break;

printf("%d",a);
return 0;

hello world

73
What will be the output of the following C code

#include<stdio.h>

void main()

int k=4;

int *const p =&k;

int r = 3;

p = &r;

printf("%d", p);

It will print address of k

Compile time error

It will print address of k + address of r

It will print address of r

74
what is the maximum degree of any vertex in a simple graph with n vertices ?
n-1

2n-1

n+1

75
What will be the output for the pseudo-code for p=22, q=127

fun(int p,int q)

if(p==0)

return q;

else

return fun(p-1 , p-q)

None of the mentioned above

Error

76
find out the number of interchanges needed to convert the given array into a max-heap.

89,19,50,17,12,15,2,5,7,11,6,9,100

3
4

77
Which of the following statements is/are TRUE for undirected graphs ?

P: Number of odd degree vertices is even.

Q: Sum of degree of all vertices is even.

Both P and Q

Neither P nor Q

Q Only

P Only

78
what will be the output of the following algorithm?

Start

Declare a, I and b

for I =0 to 4

Increment a by 1

if I = 3 then

print hello

get out of the loop

End if

End for

print a

hello

hello4
1

79
what will be the output of the following pseudocode?

Input m =9,n = 6

m = m + 1

n = n + 1

m = m + n

if(m>n)

print m

else

print n

10

17

80
what will be the output of the following pseudocode?

Declare variable x, y and i

Set x =0 and y =1

for(int i=1; i<=4; i=i+1)

print x

x = x + y

y = x / y

End of loop
0138

1024

0123

0124

81
what will be the output of the following pseudo code ?

Input f = 6,g = 9 and set sum = 0

Integer n

if (g > f)

for(n=f; n<g; n=n+1)

sum=sum+n

End of loop

else

print Error messages

print sum

21

15

82
what will be the output of the following pseudocode?

Input : 5

Algorithm(integer num)

set Integer i=2


while i<=num/2

if num mod i = 0

print "unsuccessful" and exit

i= i+1;

if (i==(num/2)+1)

print "successful"

Undefined behaviour of the algorithm

It will not print anything

Un- Successful

Successful

83
what will be the output of the following pseudocode?

Input n = 1234

Integer q, r and rn

Set q=n and rn = 0

While (q > 0)

r = q mod 10

rn = rn + r^3

q= q / 10

End of loop

print rn

321

110

100
36

84
what will be the output of the following pseudocode?

function(Input a, Input b)

if(a < b)

return function b,a)

Elseif (b !=0)

return(a + function(a, b-1))

else

return 0

65

None of the mentioned above

78

82

85
Consider the following operation along with Enqueue and Dequeue Operation on queues, where k is a global parameter

MultiDequeue (Q)

n = k

while (Q is not empty) and (n > 0)

Dequeue (Q)

n = n - 1

}
What is the worst-case time complexity of a sequence of ‘m’ Multiplexer () operation on an initially empty-queue?

0(m+k)

0(mk)

0(m^2)

0(m)

86
Which one correctly defines Full-Adder?

Option:-

A-An adder circuit having two inputs used to add two binary digits. It produces their sum and carries as Input.

B-An adder circuit having three inputs used to add two binary digits plus a carry. It produces their sum and carry as

outputs.

C-An adder circuit used in the least significant position when adding two binary digits with no carry-in to consider. It

produces their sum and carry as outputs.

D-An adder circuit having two inputs and two outputs.

87 Predict the output of the given pseudo code if the value of the number is 6:
Read number
k=2
i=2
while i <= number:
k=k*i
i = i +1
end while
write k
a)1440.0
b)1340.0
c)1700.0
d)1560.0

88 What will happen for the below pseudocode:


Set Integer res = 0
do
--res
display res
res++
While(res >= 0)
End do-while

89 What will be the output of the following pseudocode for p = 3 and q = 4?

int fun1(int p, int q)

if(q EQUALS 0)

return 0

if(q mod 2 EQUALS 0)

return fun1(p + p, q/2) .

return fun1(p + p, q/2) + p

End function fun1()

A. None of the options

B. 7

C. 12

D. 8
90 What will be the output of the following pseudocode?

Integer x, y, Z, a

Set x=2,y=1,z=5
a = (x AND y) OR (z + 1)

Print a

A. 5

B. 3

C. 2

D. 1
91 What will be the output of the following pseudocode for a = 2, b = 3?

doSomething(Integer a, Integer b)

if(b EQUALS 1)

return 0

else

return a+ doSomething(a, b-1)

End function doSomething()

A. 3

B. 4

C. 2

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

Integer a, n, sum, q, r

Set a=123, n=0, sum=0

Set q=a

while (q mod 10 NOT EQUALS 0)

n=n+1

q=q/10

End while

Print n

while (a greater than 0)


r=a mod 10

sum =sum + r

a =a/power(10, n- 1)

End while

Print sum

A. 3 2

B. 6 4

C. 6 5

D. 3 4
93 What will be the output for the following pseudocode?

Integer a=5,b=8,c

if(a>8 OR b < 7)

c=a+b

elseif(a + b > 9)

c=a-b

else

a=a+5

c=c-2

end if

a=a+b

Print a and c

b=b-5

[Note: OR — The logical Or operator returns the Boolean value if either or both operands
are true and returns false otherwise.]

A. None of the mentioned

B. 5 -3
C. 5 1

D. 13 -3

94 What will happen when following pseudocode is executed?

A. Code executes successfully and value of salary is displayed once.

B. Code executes successfully and nothing is displayed.

C. Code executes successfully and value of salary is displayed infinite number of times.

D. Compile time error.


95 What will happen when following program is executed?

A. Code will run infinite number of times.

B. The program will not enter the loop.

C. Code will execute and value of res will be displayed twice.

D. Code will execute and value of res will be displayed once.

96 How many times will ‘#’ be displayed?


A. 15

B. 1

C. 2

D. 8

97 What will be the output of the following pseudocode?

A. 0

B. 3

C. 1

D. 2
98 What will be the output of the following pseudocode?

A. SevenTwoHello
B. OneHello

C. SevenTwo

D. Seven
99 What will be the output of the following pseudocode?

A. 3

B. 5

C. 8

D. None of these
100 What will be the output of the following pseudocode?

A. 0

B. 1

C. 2

D. 7
101 What will be the output of the following pseudocode?
A. 3

B. 0

C. 10

D. 2
102 What will be the output of the following pseudocode?

A. 40

B. 100

C. 300

D. None of these

103 What will be the output of the following pseudocode?

A.1

B. 2

C. 0
D. None of these
104
What will be the value of the following pseudocode?

Integer value, n, num

Set value = 1, n = 45

num = num >> 1

num = num + value

Print num

A.44

B.0

C.1

D.12

105 What will be the value of the following pseudocode?

Integer x, y

for(each x from 1 to 11)

x=x+2

end for

Print x

A.11

B.10

C.12

D.13
106 What will be the value of the following pseudocode?

Integer j, m

Set m = 1, j = 1

Integer a[3] = {0, 1, 0}

a[0] = a[0] + a[1]

a[1] = a[1] + a[2]

a[2] = a[2] + a[0]

if(a[0])

a[j] = 5

End if

m = m + a[j]

Print m

A.3

B.2

C.6

D.4

107 What will be the value of the following pseudocode for k=150?

fun(integer k)

if(k>155)

return

end if

print k
fun(k+2)

print k

End of function fun()

A. 150 152 154

B. 150 152 154 154 152 150

C. 150

D. None of the mentioned

108 What will be the output of the following pseudocode?

Integer a[5], b[5], c[5], k, l

Set a[5] = {5, 9, 7, 3, 1}

Set b[5] = {2, 4, 6, 8, 10}

for(each k from 0 to 4)

c[k] = a[k] - b[k]

end for

for(each 1 from 0 to 4)

Print c[1]

end for

A. 7 13 13 11 11

B. 3 5 1 -5 -9

C. -3 -5 -1 5 9

D. None

109 How many times “A” will be printed in the following pseudocode?
Integer a, b, c

for(a = 0 to 4)

for(b = 0 to 2)

if(a is greater than b)

Print “A”

End for

End for
End if

A.8

B.7

C.9

D.10

110 What will be the output of the following pseudocode?

Integer p, q, r

Set q = 13

for(each p from 1 to 4)

r = q mod p

p=p+5

q=p+r

end for r = q / 5

Print q, r

A.6 4

B.1 3
C.7 2

D.6 1

111 What will be the output of the following pseudocode?

Integer x

Set x = 259 if(x EQUALS 0)

Print “0”

otherwise if(x MOD 9 EQUALS 0)

Print “9”

otherwise

Print x MOD 9

end if

A. 8

B. 16

C. 7

D. None

112 What will be the output of the following pseudocode?

Integer a, b

Set a = 12, b = 25

a = (a + b) MOD 2

b=b=a

a = a + b - 13

Print a, b
A. -11 1

B. -12 00

C. 11 22

D. 37 24

113 What will be the output of the following pseudocode?

Integer a, b, c

Set a = 4, b = 4, c = 4

if (a & (b ^ b) & c)

a = a >> 1

End if

Print a + b + c

A.16

B.24

C.8

D.12

114 What will be the output of the following pseudocode for a = 10, b =
11?

Integer funn(Integer a, Integer b)

if(0)

return a - b - funn(-7, -1)

End if

a=a+a+a+a
return a

End function funn()

A.40

B.30

C.44

D.0

115 What will be the output of the following pseudocode for a = 5, b = 1?

Integer funn(Integer a, Integer b)

if(b + a || a - b) && (b > a) && 1)

a = a+b+b-2

return 3-a

Else

End if

return a-b+1

return a+b End function fun()

A.0

B.5

C.16

D.11

116 What will be the output of the following pseudocode for a = 5, b = 1?

Integer funn(Integer a, Integer b)

if((b mod a && a mod b) || (a ^ b > a))


a=a^b

Else

End if

return a-b

return a+b

End function funn()

A.-9

B.5

C.6

D.21

117 What will be the output of the following pseudocode for a = 4, b = 8?

Integer funn(Integer a, Integer b)

if(a > b)

End if

if(b > a)

End if

b=b^a

a=a^b

return a + b

End function funn()

A. 35

B. 20
C. 14

D. 25

118 What will be the output of the following pseudocode?

Integer x

Set x = 2

if(x is EQUAL TO 1)

if(x IS EQUAL TO 0)

Print “A”

else

Print “B”

end if

else

Print “C”

end if

A.B C

B.C

C.A

D.B

119 Consider the below given fragment of code.

int f(int &x, int c) {

c = c - 1;

if (c == 0) retum 1;

x = x + 1;
return f(x, c) * x;

In above program the first parameter is passed by reference and the second parameter is
passed by value. If the value of p = 5 before the call then what is the value that returned
by f(p, p)?

A. 6561

B. 161051

C. 55440

D. 3024
120 What will be the value of s if n=127?

Read n

i=0,s=0

Function Sample(int n)

while(n>0)

r=n%l0

p=8^i

s=s+p*r

i++

n=n/10

End While

Return s;

End Function

A. 27

B. 187

C. 87

D. 120
121 What will be the output if limit = 6?
Read limit n1 = 0, n2= 1, n3=1, count = 1;

while count <= limit

count=count+1

print n3

n3 = n1 + n2

n1 = n2

n2 = n3

End While

A. 1235813

B. 12358

C. 123581321

D. 12358132

122 What will be the value of even_counter if number = 2630?

Read number

Function divisible(number)

even_counter = 0, num_remainder = number;

while (num_remainder)

digit = num_remainder % 10;

if digit != 0 AND number % digit == 0

even_counter= even_counter+1

End If

num_remainder= num_remainder / 10;

End While

return even_counter;

A. 3

B. 4
C. 2

D. 1
123 What will be the value of t if a = 56 , b = 876?

Read a,b

Function mul(a, b)

t=0

while (b != 0)

t=t+a

b=b-1

End While

return t;

End Function

A. 490563

B. 49056

C. 490561

D. None of the mentioned


124 What will be the value of even_counter if number = 2630?

Read number

Function divisible(number)

even_counter = 0, num_remainder = number;

while (num_remainder)

digit = num_remainder % 10;

if digit != 0 AND number % digit == 0

even_counter= even_counter+1

End If

num_remainder= num_remainder / 10;


End While

return even_counter;

A. 3

B. 4

C. 2

D. 1
125 What will be the value of t if a = 56 , b = 876?

Read a,b

Function mul(a, b)

t=0

while (b != 0)

t=t+a

b=b-1

End While

return t;

End Function

A. 490563

B. 49056

C. 490561

D. None of the mentioned


126 What will be the output of the following pseudo code?

For input a=8 & b=9.

Function(input a,input b)

If(a<b)

return function(b,a)

elseif(b!=0)

return (a+function(a,b-1))
else

return 0

A. 56

B. 88

C. 72

D. 65
127 What will be the output of the following pseudo code?

Input m=9,n=6

m=m+1

N=n-1

m=m+n

if (m>n)

print m

else

print n

A. 6

B. 5

C. 10

D. 15
128 What will be the output of the following pseudo code?

Input f=6,g=9 and set sum=0

Integer n

if(g>f)

for(n=f;n<g;n=n+1)

sum=sum+n

End for loop


else

print error message

print sum

A. 21

B. 15

C. 9

D. 6

129 What will be the output if limit = 6?

Read limit n1 = 0, n2= 1, n3=1, count = 1;

while count <= limit

count=count+1

print n3

n3 = n1 + n2

n1 = n2

n2 = n3

End While

A. 1235813

B. 12358

C. 23581321

D. 12358132

130 Count the number of " * " printed by the given pseudo code when the input is 25.
Write "Please enter a number"
Read input
Repeat while input > 0
if( input > 0 and input <=12 )
Write *
else if ( input >12 and input <=24 )
Write **
else if ( input >24 and input< = 30 )
Write ***
input --
end if
End while

You might also like