Capgemini Coding MCQ Questions

Question 1

Time: 00:00:00
Question:
What is the output of the following code?

void my_recursive_function(int n){

if(n==0)

return;

printf("%d",n);

my_recursive_function(n-1);

}

int main(){

my_recursive_function(10);

return 0;

}

10

10

1

1

10 9 8 ... 1 0

10 9 8 ... 1 0

10 9 8 ... 1

10 9 8 ... 1

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Question 2

Time: 00:00:00
Question: A NAND gate has:

 

LOW inputs and a HIGH output

LOW inputs and a HIGH output

LOW inputs and a LOW output

LOW inputs and a LOW output

HIGH inputs and a HIGH output

HIGH inputs and a HIGH output

None of these

None of these

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

PrepInsta User

NAND date is the reverse of and gate AND gate is high input and high outputs as for reverse of NAND is low input and low output. 1 1 is 0 for NAND 1 1 is 1 for AND

Question 3

Time: 00:00:00
Question: Convert the following 211 decimal number to 8-bit binary?

11011011

11011011

11001011

11001011

11010011

11010011

11010011

11010011

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

PrepInsta User

Use the basic trick do the binary calculation by 2 then will get 11010011

Question 4

Time: 00:00:00
Question: What is the output of this C code?

#include <stdio.h>

int main(){

int i = 12;

int *p = &i;

printf("%d"\n,*p++);

}

Address of i++

Address of i++

12

12

Garbage Value

Garbage Value

Address of i

Address of i

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Question 5

Time: 00:00:00
Question: Consider the following iterative implementation
to find the factorial of a number:

int main(){

int n =6, i;

int fact = 1;

for(i=1;i<=n;i++){

_________

printf("%d",fact);

return 0;




}

}

Which of the following lines should be inserted to complete the above code?

fact = fact + i

fact = fact + i

fact = fact * i

fact = fact * i

i = i * fact

i = i * fact

i = i + fact

i = i + fact

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

PrepInsta User

For factorial program the condition is must and should fact=fact*i let\'s check i is 0 and fact is 1 that declared in program. Check the conditions then we get the exact factorial of any number

Question 6

Time: 00:00:00
Question: Point out the error in the program?

#include<stdio.h>

int main(){

char ch;

int i;

scanf("%c", &i);

scanf("%d", &ch);

printf("%c %d", ch, i);

return 0;

}

 

Error: suspicious char to in conversion in scanf()

Error: suspicious char to in conversion in scanf()

Error: we may not get input for second scanf() statement

Error: we may not get input for second scanf() statement

No Error

No Error

None of the above

None of the above

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

PrepInsta User

In the program we use the int data type for i but in the scanf we entered as %c. For int type we must use %d. So there no input for scanf()

["0","40","60","80","100"]
["Need more practice! \n","Keep trying! \n","Not bad! \n","Good work! \n","Perfect! \n"]