Programs

Question 11 :

Which of the following statement is correct about the program given below?

#include < iostream . h > 
enum xyz
{
    a, b, c
};
int main() 
{
    int x = a, y = b, z = c;
    int &p = x, &q = y, &r = z;
    p = ++x;
    q = ++y;
    r = ++c;
    cout<< p << q << r;
    return 0;
}


A). The program will print the output 1 2 3.
B). The program will print the output 2 3 4.
C). The program will print the output 0 1 2.
D). It will result in a compile time error.
Answer : Option D

Question 12 :

Which of the following statement is correct about the program given below?

#include < iostream . h > 
int main()
{
    int arr[] = {1, 2 ,3, 4, 5}; 
    int &zarr = arr;
    for(int i = 0; i <= 4; i++)
    {
        arr[i] += arr[i];
    }
    for(i = 0; i <= 4; i++)
        cout<< zarr[i]; 
    return 0; 
}


A). The program will print the output 1 2 3 4 5.
B). The program will print the output 2 4 6 8 10.
C). The program will print the output 1 1 1 1 1.
D). It will result in a compile time error.
Answer : Option D

Question 13 :

Which of the following statement is correct about the program given below?

#include < iostream . h > 
struct Parinam
{
    short n;
};
int main()
{
    Parinam b;
    Parinam& rb = b;
    b.n = 5;
    cout << b.n << " " << rb.n << " ";
    rb.n = 8;
    cout << b.n << " " << rb.n;
    return 0; 
}


A). It will result in a compile time error.
B). The program will print the output 5 5 5 8.
C). The program will print the output 5 5 8 8.
D). The program will print the output 5 5 5 5.
Answer : Option C

Question 14 :

What will be the output of the following program?

#include  < iostream . h > 
enum xyz 
{
    a, b, c
}; 
int main()
{
    int x = a, y = b, z = c; 
    int &p = x, &q = y, &r = z; 
    p = z; 
    p = ++q;
    q = ++p;
    z = ++q + p++; 
    cout<< p << " " << q << " " << z;
    return 0; 
}


A). 2 3 6
B). 4 4 7
C). 4 5 8
D). 3 4 6
Answer : Option B

Question 15 :

Which of the following statement is correct about the program given below?

#include < iostream . h > 
int ParinamFunction(int m)
{
    m *= m;
    return((10)*(m /= m)); 
}
int main()
{
    int c = 9, *d = &c, e;
    int &z = e;
    e = ParinamFunction(c-- % 3 ? ++*d :(*d *= *d));
    z = z + e / 10;
    cout<< c << " " << e;
    return 0;
}


A). It will result in a compile time error.
B). The program will print the output 64 9.
C). The program will print the output 64 10.
D). The program will print the output 64 11.
Answer : Option D