Capgemini Pseudo Code Online Test Questions and Answers

Capgemini pseudo code on line test is conducted by Co cubes, It is the second elimination round after the Aptitude and Essay Topic Round, In this round there will be 20 MCQ questions with 20 minutes of time duration,the questions mainly come from C, C++, Data Structure commands, and syntaxes, type of questions like finding the error in the code, finding the out put of the code, line insertion questions, binary search tree , recursion, functions, loop ,pointers and switch case related questions.

Capgemini Pseudo Code Questions

Here is the sample pseudo questions asked in placement drive:

 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: we may not get input for second scanf() statement
 No error
 None of above


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
i = i * fact
 i = i + fact



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++
12
Garbage value
Address of i


Question: Convert the following 211 decimal number to 8-bit binary?
11011011
11001011
11010011
11010011


Question: A NAND gate has:
LOW inputs and a HIGH output
LOW inputs and a LOW output
HIGH inputs and a HIGH output
None of these


Question: Comment on the output of this C code?
    #include <stdio.h>
    int main()
    {
        int a = 1;
        switch (a)
        case 1:
            printf("%d", a);
        case 2:
            printf("%d", a);
        case 3:
            printf("%d", a);
        default:
            printf("%d", a);
    }

 No error, output is 1111
 No error, output is 1
 Compile time error, no break statements
 Compile time error, case label outside switch statement


Question: How will you find the maximum element in a binary search tree?
a)
public void max(Tree root)
{
            while(root.left() != null)
            {
                        root = root.left();
            }
            System.out.println(root.data());
}

b)
public void max(Tree root)
{
            while(root != null)
            {
                        root = root.left();
            }
            System.out.println(root.data());
}

c)
public void max(Tree root)
{
            while(root.right() != null)
            {
                        root = root.right();
            }
            System.out.println(root.data());
}

d)
public void max(Tree root)
{
            while(root != null)
            {
                        root = root.right();
            }
            System.out.println(root.data());
}



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
1
10 9 8 … 1 0
10 9 8 … 1


Previous Post Next Post