Technical Questions asked in Makemytrip

  1. 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?
    1. Statement 1
    2. Statement 2
    3. Statement 3
    4. Statement 4

    Answer : Option B.
deloitte article
  1. Which of the following statements is true after execution of the program?
    int a[10],I,*p;
    a[0] = 1;
    a[1] = 2;
    p = a;
    (*p)++;
    1. a[0] = 2
    2. a[1] = 3
    3. a[1] = 1
    4. a[0] = 3

    Answer : Option A.
  2. Predict the output of following C++ program.
    #include
    using namespace std;
    class abc
    {
    static int x;
    public:
    abc() { x++;}
    static int getX() {return x;}
    };
    int Test::x = 0;
    int main()
    {
    cout << abc::getX() << " ";
    abc t[5];
    cout << abc::getX(); }
    1. 55
    2. 55
    3. 05
    4. 50

    Answer : Option C.
    abc::getX()" is a static function so it can be called without object. Since x is initialized as 0, the first call to getX() returns 0. As x++ in constructor and when an array of 5 objects is created, the constructor is called 5 times. So x is incremented to 5 before the next call to getX().
  3. What will be output of following program?
    #include
    int main()
    {
    int huge *a =(int huge *)0x59990005;
    int huge *b =(int huge *)0x59980015;
    if(a == b)
    printf("power of pointer");
    else
    printf("power of c");
    return 0;
    }
    1. power of pointer
    2. power of c
    3. power of c power of c
    4. Compilation error

    Answer : Option A.
  4. Assume that the Point class is existing with the following snippet in the header file
    Point.h:
    class Point
    {
    Point(); Pont(int, int); int GetX();
    int GetY();
    void SetX(int);
    void SetY(int);
    };
    If the objects of Point are created as Point oPointOne, oPointTwo(2,3); Which of the following statements are correct?
    (i)The statement oPointOne.SetX(20);
    Will compile and run successfully.
    (ii) The statement oPointOne.SetX(20).SetY(30);
    Will compile successfully but will give a run time error.
    1. Only (i) is correct
    2. Both (i) and (ii) are correct
    3. Both (i) and (ii) are incorrect
    4. Only (ii) is correct

    Answer : Option A.
  5. What is the complexity of this algorithm?
    Algorithm Sum (a,n)
    {
    s := 0.0;
    for i := 1 to n do s := s + a [i];
    return s;
    1. log2n
    2. O(n)
    3. O(n log n)
    4. O(kn)

    Answer : Option B.
Campus Placement ad
Rate Us
Views:6202