References

1

Identify the correct sentence regarding inequality between reference and pointer.

A. we can not create the array of reference.
B. we can create the Array of reference.
C. we can use reference to reference.
D. none of the mentioned

2

What is the output of this program?

1.
    #include 
2.    
    using namespace std;
3.    
    void print (char * a)
4.    
    {
5.    
        cout << a << endl;
6.        
    }
7.    
    int main ()
8.    
    {
9.    
        const char * a = "Hello world";
10.        
        print(const_cast (a) );
11.        
        return 0;
12.        
    }
A. Hello world
B. Hello
C. world
D. compile time error

3

What is the output of this program?

1.
    #include 
2.    
    using namespace std;
3.    
    int main()
4.    
    {
5.    
        int a = 9;
6.        
        int & aref = a;
7.        
        a++;
8.        
        cout << "The value of a is " << aref;
9.        
        return 0;
10.        
    }
A. 9
B. 10
C. error
D. 11

4

What does a reference provide?

A. Alternate name for the class
B. Alternate name for the variable
C. Alternate name for the pointer
D. none of the mentioned

5

What is the output of this program?

1.
    #include 
2.    
    using namespace std;
3.    
    void swap(int &a, int &b);
4.    
    int main()
5.    
    {
6.    
        int a = 5, b = 10;
7.        
        swap(a, b);
8.        
        cout << "In main " << a << b;
9.        
        return 0;
10.        
    }
11.    
    void swap(int &a, int &b)
12.    
    {
13.    
        int temp;
14.        
        temp = a;
15.        
        a = b;
16.        
        b = temp;
17.        
        cout << "In swap " << a << b;
18.        
    }
A. In swap 105 In main 105
B. In swap 105 In main 510
C. In swap 510 In main 105
D. none of the mentioned