References

1

What will be the output of the following program?

#include  
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

2

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

#include 
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.

3

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

#include 
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.

4

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

#include 
int main()
{
    int m = 2, n = 6;
    int &x = m++;
    int &y = n++;
    m = x++; 
    x = m++;
    n = y++;
    y = n++;
    cout<< m << " " << n; 
    return 0; 
}
A. The program will print output 3 7.
B. The program will print output 4 8.
C. The program will print output 5 9.
D. The program will print output 6 10.
E. It will result in a compile time error.

5

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

#include 
int main()
{
    int m = 2, n = 6;
    int &x = m;
    int &y = n;
    m = x++; 
    x = m++;
    n = y++;
    y = n++;
    cout<< m << " " << n; 
    return 0; 
}
A. The program will print output 2 6.
B. The program will print output 3 7.
C. The program will print output 4 8.
D. The program will print output 5 9.
E. The program will print output 6 10.