References


  1. What is the output of this program?
    #include 
    using namespace std;
    void print (char * str)
    {
    cout << str << endl;
    }
    int main ()
    {
    const char * str = "Interview Mania";
    print(const_cast (str) );
    return 0;
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    In this program we used the concept of constant casting to cast the variable and printing it.


  1. What does a reference provide?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: A

    Because we are pointing memory address using the temp variable.



  1. What is the output of this program?
    #include 
    using namespace std;
    int main()
    {
    int num = 11;
    int & numref = num;
    num++;
    cout << "The value of num is " << numref;
    return 0;
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: A

    The value is declared and it isincrementedrement, so it’s value is 11.


  1. What is the output of this program?
    #include 
    using namespace std;
    void swap(int &p, int &q);
    int main()
    {
    int p = 5, q = 10;
    swap(p, q);
    cout << " In main " << p << q;
    return 0;
    }
    void swap(int &p, int &q)
    {
    int temp;
    temp = p;
    p = q;
    q = temp;
    cout << "In swap " << p << q;
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: E

    As we are calling by reference the values in the address also changed. So the main and swap values also changed.



  1. Identify the correct sentence regarding inequality between reference and pointer.











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: B

    we can not create the array of reference