0% found this document useful (0 votes)
49 views14 pages

Cap Gemini 3

Uploaded by

Kaushiki Mishra
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)
49 views14 pages

Cap Gemini 3

Uploaded by

Kaushiki Mishra
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/ 14

Capgemini Pseudocodes-I

Q1. What will be the output.


#include <stdio.h>
void main ()
{
long double a;
signed char b;
int arr [sizeof(!a+b)] ;
printf("%d",sizeof(arr));

}
a)64
b)16
c)36
d)32

Q2. What will be the output


#include<stdio.h>
int main()
{
int y=1;
int z;
z =(y++,y);
printf("%d\n", z);
return 0;
}
a)2
b)1
c)0
d)Compilation Error

Q3. What is the maximum degree of any vertex in a simple graph with n+1 vertices?

a)n + 1
b)2n - 1
c)n
d)n-1

Q4.What will be the returned value if 1234 is passed in fun1

int fun1 (int num){


static int a = 0;
if ( num> 0)
{
a=a+1;
fun1(num/10);}
else
return a;
}

a)3
b)7
c)4
d)0

Q5.
#include <stdio.h>
void main (){
int ch=1;
switch(ch){
case 1:
printf("1");
case 2:
printf("2");
break;
default:
printf("3");
}}

a)1
b)2
c)123
d)12
Q6. What will be the output if n=2
int fun( int n )
if(n EQUALS 4)
return n
else
return 3 * fun (n+ 1)

a)12
b)16
c)36
d)48

Q7. Which of the following data structure cannot store even if total number of elements is
less than maximum?

a)Circular queue
b)None of the mentioned options
c)Priority queue
d) Simple queue

Q8. What will be the output.


Integer value, n
Set value
value=1, n = 67
while (value less than equal to n)
value = value << 1
end loop
Print value

a)64
b)128
c)48
d)256
Q9. What will be the output
Integer a, b, C
Set a = 8, b = = 10, c =6
If (a > c AND (b + c) >a)
Print a
end if
if (c>b or (a + c)> b)
Print b
end if
if ( (b+c) MOD a EQUALS 0)
Print c
End if

a)2
b)3
c)1
d)0

Q10. What will be the min heap representation if smallest is removed


7 8 9 16 12 43

a)8 12 16 9 43
b)8 9 12 16 43
c)8 12 9 43 16
d)8 12 9 16 43

Q11. What will be the height of BST if following elements are inserted from left to right?

31 24 26 37 42 32

a)5
b)6
c)4
d)3

Q12.

How many times is the comparison i≥n performed in the following program?

int i=105, n=5;


main() {
while (i >= n) {
i=i-1;
n=n+1;
}
}

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

Q13.

Consider the following pseudocode fragment, where y is an integer that has been initialized.

int i=1
int j=1
while (i<5):
j=j*i
i=i+1
if (i==y):
break
end if
end while

Consider the following statements:

1. (i==5) or (i==y)

2. If y>5, then i==5

3. If j=16, then y==4

Which of the above statements is/are TRUE at the end of the while loop? Choose from the
following options.

A. 1 only
B. 2 only
C. 1 and 2 only
D. 1, 2 and 3

Q14. ^ is used here to represent power


x=1;
i=1;
while (x <= 10)
begin
x:=2^x;
i:=i+1;
end;

What is the value of i at the end of the pseudo-code?

a)5

b)4

c)6

d)3

Q15. What will be the output?

unsigned long int fun(unsigned long int n) {


unsigned long int i, j = 0, sum = 0;
for( i = n; i > 1; i = i/2) j++;
for( ; j > 1; j = j/2) sum++;
return sum;
}

The value returned when we call fun with the input 270 is

a)5

b)4

c)10

d)6

Q16. If the base address of a two-dimensional array A [70] [10] is 700, then what is the
address of an element A [2] [7] in the array?

a)808

b)708

c)712

d)812
Q17. What will be the output?

Integer a, b, c, d

Set b = 10, c= 10

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)0 10 20

b)6 4 16

c)6 4 15

d)9 10 21

Q18. What will be the output?

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


p=q mod r
q=q+p
r=r+q
print p, q and r
a)8 16 26

b)7 14 24

c)8 14 24

d)8 14 26

Q19. What is the output of following function for start pointing to rst node of following
linked list? 1->2->7->4->5->6

fun(struct node* start)


if start = Null
return;
print start->data
if start->next != NULL
call fun(start->next->next)
print start->data

a) 175571
b) 135135
c) 175175
d) 1756

Q20 What will be the array representation of min heap after inserting 10 to it.

12 43 16 56 98 23

a)10 12 43 56 98 23 16

b) 10 43 12 56 98 23 16

c) 10 43 12 56 23 98 16

d) 10 43 56 98 12 23 16

Q21 Convert the infix expression to postfix

A+B/(C+D-F)*Y-X

a) ABCD+F-/Y*-X+
b) ABCD+F-*Y/-X+
c) ABCD+F-/Y*+X-
d) ABCD-F+/Y*+X-

Q22.What will be the output

#include<stdio.h>
int main()
{
printf("360");
main();
return 0;
}

a) Compilation Error
b)360 is printed once
c)Nothing will get printed
d)360 will be printed infinity times

Q23.How much memory recursion requires as compare to iteration.

a)Less than Iteration


b)More than Iteration
c)Same as Iteration

Q24. What is the result of the following postfix expression?

ab*cd** where a=2, b=2, c=3, d=4.

a)16

b)48

c)36

d)24

Q25. What are the dimensions of an incidence matrix?

a) Number of edges*number of edges


b) Number of edges*number of
vertices

c)Number of vertices*number of
vertices

d)None of the mentioned statements

Q26 What will be the output?

input m=9,n=7
m=m+1
n=n-1
m=m+n
if(m>n)
print m
else
print n

a)16
b)15
c)6
d)5

Q27. The worst case in a linear search occurs when

a)Item in middle of array

b) Item is last element of array

c)Item not there in array

d)All of these
Q28. Which of the following will return a result most quickly for searching a given key?

a) Unsorted Array

b) Sorted Array

c)Sorted linked list

d)Binary Search Tree

Q29. What will be the output?

if a=10 and b=6:

Integer func (Integer a, Integer b)

Integer temp

while (b)

temp =a MOD b

a=b

b = temp

end while

return a
End function func ()

a)2

b)4

c)3

d)1

Q30.What will be the output?

Integer a
String str1
Set str1 = “rainbow”
a = stringLength(str1)
Print (a ^ 1)

a)4
b)5
c)7
d)6
ANSWERS
1-b
2-a
3-c
4-c
5-d
6-c
7-d
8-b
9-b
10-d
11-d
12-a
13-c
14-b
15-d
16-a
17-a
18-a
19-a
20-b
21-c
22-d
23-b
24-b
25-b
26-a
27-b,c
28-d
29-b
30-d

You might also like