Capgemini Aptitude Questions
CapGemini Study Material

Capgemini and Hexaware Technical Programming Questions: Study Material 2020-2021 Batch

Capgemini and Hexaware Study Material: Last year placement papers:

Capgemini Study Material 2020-2021 Batch includes Capgemini Aptitude Questions, Capgemini Logical Reasoning Questions, Capgemini Technical Programming Questions, Capgemini Pseudo Code Questions with Explanation, Capgemini Sample Verbal Ability Questions, C Programming MCQs

Must Read:

Capgemini Technical Programming Questions: Capgemini Study Material

Q1. Consider 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+1; printf(“%d,%d,%d\n”,i,a,*b);
}

A. 2,1,8
B. 4,1,8
C. 4,4,8
D. 2,4,8

Ans. A

Q2. There is a new data-type which can take as values natural numbers between (and including) 0 and 25. How many minimum bits are required to store this datatype.

A. 4
B. 5
C. 1
D. 3

Ans. B

Q3. Stack is useful for implementing:

A. Recursion
B. Depth first search
C. Both (A) & (B)
D. Breadth first search

Ans. C

Q4. A data type is stored as an 6 bit signed integer. Which of the following cannot be represented by this data type?

A. -12
B. 0
C. 32
D. 18

Ans. C

Q5. What will be the output of the following loop?

#include<stdio.h>

main()
{
while(printf(“%d”, printf(“az”)))
printf(“by”);
}

A. None of these
B. Syntax error
C. azbyazbyazbyazby…
D. azbybyby…

Ans. C
Q6. A language has 28 different letters in total. Each word in the language is composed of maximum 7 letters. You want to create a data-type to store a word of this language. You decide to store the word as an array of letters. How many bits will you assign to the data-type to be able to store all kinds of words of the language.

A. 7
B. 35
C. 28
D. 196

Ans. B

Q7. Predict the output :

char c[ ] = “DATA1234”
char * P = C;
printf (“%S” P+P[3]-P[1]);

A. DATA1234
B. 234
C. 1234
D. A1234

Ans. A

Q8. A 10-bit unsigned integer has the following range:

A. 0 to 1000
B. 0 to 1024
C. 1 to 1025
D. 0 to 1023

Ans. D

 

 

Q9. Predict the output ?

struct abc
{
int b=6;
char c;
}
structure;
int main()
{
int i=sizeof(structure);
printf(“%d”,i);
}
A.4
B.1
C.2
D.6

Ans. D

Q10. Rajni wants to create a data-type for the number of books in her book case. Her shelf can accommodate a maximum of 75 books. She allocates 7 bits to the datatype. Later another shelf is added to her book-case. She realizes that she can still use the same data-type for storing the number of books in her book-case. What is the maximum possible capacity of her new added shelf?

A. 52
B. 127
C. 53
D. 75

Ans. A

Capgemini Technical Programming Questions
Q11. A new language has 15 possible letters, 8 different kinds of punctuation marks and a blank character. Rahul wants to create two data types, first one which could store the letters of the language and a second one which could store any character in the language. The number of bits required to store these two data-types will respectively be:

A. 3 and 4
B. 4 and 3
C. 4 and 5
D. 3 and 5

Ans. C

Q12. Consider the following code:

function modify(b,a)
{
return a – b
}
function calculate( )
{
integer a = 5, b = 12, c
c = modify(a, b);
print(“%d”,c);
}

Assume that a and b were passed by reference. What will be the output of the program on executing function calculate( ) ?

A. 7
B. -7
C. Error
D. 8

Ans. A

Q13. Consider the following code:

function modify(y,z)
{
y = y + 1
z = z + 1
return y – z
}
function calculate( )
{
integer a = 12, b = 20, c
c = modify(a, b);
print a
print space
print c
}
Assume that a and b were passed by reference. What will be the output of the function calculate( ) ?

A. 12 -8
B. 13 -8
C. 12 8
D. 13 8

Ans. B

Q14. Ankita takes as input 2 integer numbers, a and b, whose value can be between 0 and 31. He stores them as 5 bit numbers. He writes the following code to process these numbers to produce a third number c.

c = 2*(a – b)

In how many minimum bits should Ankita store c?

A. 6 bits
B. 7 bits
C. 8 bits
D. 9 bits

Ans. B

Capgemini Technical Programming Questions

Q15. A character in new programming language is stored in 2 bytes. A string is represented as an array of characters. A word is stored as a string. Each byte in the memory has an address. The word “Mahatma Gandhi” is stored in the memory with starting address 456. The letter ‘d’ will be at which memory address?

A. 468
B. 480
C. 478
D. 467

Ans. C
Q16. Stuti is making a questionnaire of True-false questions. She wants to define a data-type which stores the response of the candidate for the question. What is the most-suited data type for this purpose?

A. integer
B. boolean
C. float
D. character

Ans. B

Q17. Afzal writes a piece of code, where a set of three lines occur around 10 times in different parts of the program. What programming concept can he use to shorten his program code length?

A. Use for loops
B. Use functions
C. Use arrays
D. Use classes

Ans. B

Q18. Geetika writes a piece of code, where a set of eight lines occur around 10 times in different parts of the program (Code A). She passes on the code to Deva. Deva puts the set of eight lines in a function definition and calls them at the 10 points in the program (Code B). Which code will run faster using an interpreter?

A. Code A
B. Code B
C. Code A and Code B will run with the same speed
D. None of these

Ans. A

Q19. Consider the following code:

function modify(a,b)
{
integer c, d = 2
c = a*d + b
return c
}
function calculate( )
{
integer a = 5, b = 20, c
integer d = 10
c = modify(a, b);
c = c + d
print c
}
Assume that a and b were passed by value. What will be the output of the function
calculate( ) ?

A. 80
B. 40
C. 32
D. 72

Ans. B

Capgemini Technical Programming Questions

Q20. Consider the following code:

function modify(w,u)
{
w = w + 2
u = u – 3
return (w – u)
}
function calculate( )
{
integer a = 10, b = 20, c
c = modify(a, b);
print a
print space
print b
}

Assume that a was passed by value and b was passed by reference. What will be the
output of the program on executing function calculate( ) ?

A. 12 17
B. 10 17
C. 12 20
D. 10 20

Ans. B
Q21. Consider the following function:

function run( )
{
integer a = 0 // Statement 1
while (a < 5)
{
integer c = 0 // Statement 2
c = c + 1 // Statement 3
a = a + 1
}
print c // Statement 4
}
At which statement in this program will the compiler detect an error?

A. Statement 1
B. Statement 2
C. Statement 3
D. Statement 4

Ans. D

Q22. Which one of the following is the lowest level format to which the computer converts a higher language program before execution?

A. English code
B. Machine Code
C. Assembly Language
D. System Language

Ans. B

Capgemini Technical Programming Questions

Q23. If you want to write a function that swaps the values of two variables, you must pass them by:

A. Value only
B. Reference only
C. Either A or B
D. Neither A nor B

Ans. B

Q24. What will be the output of the following pseudo-code statements:

integer a = 984, b, c, d =10
print remainder(a,d) // remainder when a is divided by d
a = a/d
print remainder(a,d) // remainder when a is divided by d

A. 48
B. Error
C. 84
D. 44

Ans. A

Q25. What will be the output of the following code statements?

integer a = 50, b = 25, c = 0
print ( a > 45 OR b > 50 AND c > 10 )

A. 1
B. 0
C. -1
D. 10

Ans. A
Q26. What will be the output of the following code statements?
integer a = 50, b = 25, c = 5
print a * b / c + c
A. 120
B. 125
C. 255
D. 250
Ans. C
Q27. What will be the output of the following code statements?
integer a = 10, b = 35, c = 5
print a * b / c – c
A. 65
B. 60
C. Error
D. 70
Ans. A
Q28. integer a = 10, b = 35, c = 5
Comment about the output of the two statements?
print a * b + c / d
print c / d + a * b
A. Differ due to left-to-right precedence
B. Differ by 10
C. Differ by 20
D. Same
Ans. D
Q29. integer a = 40, b = 35, c = 20, d = 10
Comment about the output of the following two statements:
print a * b / c – d
print a * b / (c – d)
A. Differ by 80
B. Same
C. Differ by 50
D. Differ by 160
Ans. A
Q30. integer a = 60, b = 35, c = -30
What will be the output of the following two statements:
print ( a > 45 OR b > 50 AND c > 10 )
print ( ( a > 45 OR b > 50 ) AND c > 10 )
A. 0 and 1
B. 0 and 0
C. 1 and 1
D. 1 and 0
Ans. D
Q31. What will be the output of the following pseudo-code statements:

integer a = 984
//float is a data-type to store rational numbers.
float b= 10, c
c = a / b
print c

A. 984
B. Error
C. 98.4
D. 98

Ans. C

Q32. Smriti wants to make a program to print the sum of square of the first 5 whole numbers (0…4). She writes the following program:

integer i = 0 // statement 1
integer sum = 0 // statement 2
while ( i < 5 ) // statement 3
{
sum = i*i // statement 4
i = i + 1 // statement 5
}
print sum // statement 6
Is her program correct? If not, which statement will you modify to correct it?

A. No error, the program is correct.
B. Statement 1
C. Statement 4
D. Statement 6

Ans. C

Q33. Shashi wants to make a program to print the sum of the first 10 multiples of 5. She writes the following program, where statement 5 is missing:

integer i = 0
integer sum = 0
while ( i <= 50 )
{
sum = sum + i
— MISSING STATEMENT 5 —
}
print sum
Which of the following will you use for statement 5?

A. i = 5
B. i = 5 * i
C. i = i + 1
D. i = i + 5

Ans. D

Q34. Shantanu wants to make a program to print the sum of the first 7 multiples of 6. He writes the following program:

integer i = 0 // statement 1
integer sum // statement 2
while ( i <= 42 ) // statement 3
{
sum = sum + i // statement 4
i = i + 6;
}
print sum // statement 6

Does this program have an error? If yes, which one statement will you modify to
correct the program?

A. Statement 1
B. Statement 2
C. Statement 3
D. Statement 4

Ans. B
Q36. Sharmili wants to make a program to print the sum of all perfect cubes, where the value of the cubes go from 0 to 100. She writes the following program:

integer i = 0, a // statement 1
integer sum = 0;
a = ( i * i * i )
while ( i < 100 ) // statement 2
{
sum = sum + a // statement 3
i = i + 1
a = ( i * i * i ) // statement 4
}
print sum

Does this program have an error? If yes, which one statement will you modify to
correct the program?

A. Statement 1
B. Statement 2
C. Statement 3
D. Statement 4

Ans. B

 

 

Q36. Bhavya wants to make a program to print the sum of all perfect squares, where the value of the squares go from 0 to 50. She writes the following program:

integer i = 1, a // statement 1
integer sum = 0
while ( a < 50 ) // statement 2
{
sum = sum + a // statement 3
i = i + 1
a = ( i * i ); // statement 4
}
print sum

Does this program have an error? If yes, which one statement will you modify to
correct the program?

A. Statement 1
B. Statement 2
C. Statement 3
D. Statement 4

Ans. A

Capgemini Technical Programming Questions

Q37. Consider the following code:

if (condition 1) {
if (condition 2)
{ // Statement A }
else
if (condition 3)
{ // Statement B}
else
{// Statement C }
else
if (condition 4)
{// Statement D}
else
{// Statement E}
}

Which of the following conditions will allow execution of statement E?

A. condition1 AND condition3
B. NOT(condition1) AND condition2 AND NOT(condition4)
C. NOT(condition2) AND NOT(condition3)
D. condition1 AND condition4 AND NOT(condition2) AND NOT(condition3)

Ans. B

Q38. Consider the following code:

if (condition 1) {
if (condition 2)
{ // Statement A }
else
if (condition 3)
{ // Statement B}
else
{// Statement C }
else
if (condition 4)
{// Statement D}
else
{// Statement E}
}

Which of the following condition will allow execution of statement A?

A. NOT(condition2) AND NOT(condition3)
B. condition1 AND condition4 AND NOT(condition2) AND NOT(condition3)
C. condition1 AND condition2 AND condition4
D. NOT(condition1) AND condition2 AND NOT(condition4)

Ans. C

Q39. What does the following function do?

function operation (int a, int b)
{
if (a < b)
{ return operation(b, a) }
else
{ return a }
}

A. Returns the max of (a,b)
B. Returns the min of (a,b)
C. Loops forever
D. Always returns the second parameter

Ans. A

Q40. What does the following function do?

function operation (int a, int b)
{
if (a > b)
{ return operation(b, a) }
else
{ return a; }
}

A. Always returns the first parameter
B. Returns the min of (a,b)
C. Returns the max of (a,b)
D. Loops forever

Ans. B
Q41. function g(int n)
{
if (n > 0) return 1;
else return -1;
}
function f(int a, int b)
{
if (a > b) return g(b-a);
if (a < b) return g(a-b);
return 0;
}
If f(a,b) is called, what is returned?

A. Always -1
B. 1 if a > b, -1 if a < b, 0 otherwise C. -1 if a > b, 1 if a < b, 0 otherwise
D. 0 if a equals b, -1 otherwise

Ans. D

Q42. function g(int n)
{
if (n > 0) return 1;
else return -1;
}
function f(int a, int b)
{
if (a > b) return g(a-b);
if (a < b) return g(b-a);
return 0;
}
If f(a,b) is called, what is returned?

A. 1 if a > b, -1 if a < b, 0 otherwise B. Always +1 C. 0 if a equals b, +1 otherwise D. -1 if a > b, 1 if a < b, 0 otherwise

Ans. C

Q43. function g(int n)
{
if (n > 0) return 1;
else return -1;
}
function f(int a, int b)
{
if (a > b) return g(a-b);
if (a < b) return g(-b+a);
return 0;
}
If f(a,b) is called, what is returned?

A. Always +1
B. 1 if a > b, -1 if a < b, 0 otherwise C. -1 if a > b, 1 if a < b, 0 otherwise
D. 0 if a equals b, -1 otherwise

Ans. B

Q44. function g(int n)
{
if (n > 0) return 1;
else return -1;
}
function f(int a, int b)
{
if (a > b) return g(b-a);
if (a < b) return g(-a+b);
return 0;
}

If f(a,b) is called, what is returned?

A. Always +1
B. -1 if a > b, 1 if a < b, 0 otherwise C. 1 if a > b, -1 if a < b, 0 otherwise
D. 0 if a equals b, -1 otherwise

Ans. B

Q45. Consider the following code:

for i= m to n increment 2
{ print “Hello!” }
Assuming m < n and exactly one of (m,n) is even, how many times will Hello be
printed?

A. (n – m + 1)/2
B. 1 + (n – m)/2
C. 1 + (n – m)/2 if m is even, (n – m + 1)/2 if m is odd
D. (n – m + 1)/2 if m is even, 1 + (n – m)/2 if m is odd

Ans. A

Capgemini Technical Programming Questions
Q46. Consider the following code:

for i= m to n increment 2
{ print “Hello!” }
Assuming m < n and (m,n) are either both even or both odd, How many times will
Hello be printed?

A. (n – m + 1)/2
B. 1 + (n – m)/2
C. 1 + (n – m)/2 if m is even, (n – m + 1)/2 if m is odd
D. (n – m + 1)/2 if m is even, 1 + (n – m)/2 if m is odd

Ans. B

Q47. Assuming n > 2, What value does the following function compute for odd n?

function f (int n)
{
if (n equals 1) { return 1 }
if (n equals 2) { return f(n-1) + n/2 }
return f(n-2) + n;
}

A. 1 + 2 + 3 + 4 + … + n
B. 1 + 3 + 5 + 7 + … + n
C. n/2 + (1 + 3 + 5 + 7 + … + n)
D. 1 + (1 + 3 + 5 + 7 + … + n)

Ans. B

Q48. Assuming n > 2, What value does the following function compute for even n?

int f (int n)
{
if (n equals 1) { return 1 }
if (n equals 2) { return f(n-1) + n/2 }
return f(n-2) + n
}

A. 1 + 2 + 3 + 4 + … + n
B. 1 + (2 + 4 + 6 + 8 + … + n)
C. 1 + n/2 + (4 + 6 + 8 + … + n)
D. 2 + 4 + 6 + 8 + … + n

Ans. D

Q49. The for loop is equivalent to a while loop when

A. There is no initialization expression
B. There is no increment expression
C. A and B combined are true
D. It is never equivalent

Ans. C

Q50. Consider the statement

while (a < 10.0) { a = a*a }
Assuming a is positive, for what value of a will this code statement result in an
infinite loop?

A. a < 1.0 B. a < sqrt(10) C. a > sqrt(10)
D. a = 0

Ans. A
Q51. int area(double radius)
{
return PIradiusradius;
}
Which of the following is always true about the function area?

A. It returns the area of a circle within the limits of double precision.
B. It returns the area of a circle within the limits of the constant PI.
C. It returns the area of a circle within the limits of precision of double, or the
constant PI, whichever is lower.
D. None of the above.

Ans. D

Q52. What does this function compute for positive n?

function f(int n)
{
if (n equals 1)
{ return 1 }
else
{ return f(n-1)/f(n-1) + n }
}

A. 1 + n
B. 1 + 2 + 3 + … + n
C. 1 + n, if n > 1, 1 otherwise
D. None of the above

Ans. C

Capgemini Technical Programming Questions

Q53. Which of these is not a data type?

A. integer
B. character
C. boolean
D. array

Ans. D

Q54. The construct “if (condition) then A else B” is for which of the following purposes?

A. Decision-Making
B. Iteration
C. Recursion
D. Object Oriented Programming

Ans. A

Q55. In a sequential programming language, code statements are executed in which order?

A. All are executed simultaneously
B. From top to bottom
C. From bottom to top
D. None of these

Ans. B
Q56. A for-loop is used for which of the following purposes?

A. Decision-Making
B. Iteration
C. Recursion
D. None of these

Ans. B

Q57. There are two loops which are nested. This implies which one of the following?

A. Two loop, one after the other
B. Two loops, one inside the others
C. One loop with two different iteration counts
D. Two loops with the same iteration count

Ans. B

Q58. How will 47 be stored as an unsigned 8-bit binary number?

A. 10111101
B. 00101111
C. 10111000
D. 00101101

Ans. B

Q59. An integer X is saved as an unsigned 8-bit number, 00001011. What is X?

A. 22
B. 11
C. 10
D. None of these

Ans. B

Q60. What will be the output of the following pseudo-code statements:

integer a = 984, b=10
//float is a data-type to store real numbers.
float c
c = a / b
print c

A. 984
B. 98.4
C. 98
D. Error

Ans. C

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *