Home / CSE MCQs / C++ - MCQs :: Pointers - C++

CSE MCQs :: C++ - MCQs

  1.  What does the following statement mean?

         int (*fp)(char*)

  2. A.
    pointer to a pointer
    B.
    pointer to an array of chars
    C.
    pointer to function taking a char* argument and returns an int
    D.
    function taking a char* argument and returning a pointer to int

    View Answer

    Workspace

    Discuss Discuss in Forum


  3. The operator used for dereferencing or indirection is ____
  4. A.
    *
    B.
    &
    C.
    ->
    D.
    ->>

    View Answer

    Workspace

    Discuss Discuss in Forum


  5. Choose the right option

         string* x, y;

  6. A.
    x is a pointer to a string, y is a string
    B.
    y is a pointer to a string, x is a string
    C.
    both x and y are pointer to string types
    D.
    none of the mentioned

    View Answer

    Workspace

    Discuss Discuss in Forum


  7. Which one of the following is not a possible state for a pointer?
  8. A.
    hold the address of the specific object
    B.
    point one past the end of an object
    C.
    zero
    D.
    point to a tye

    View Answer

    Workspace

    Discuss Discuss in Forum


  9. Which of the following is illegal?
  10. A.
    int *ip;
    B.
    string s, *sp = 0;
    C.
    int i; double* dp = &i;
    D.
    int *pi = 0;

    View Answer

    Workspace

    Discuss Discuss in Forum


  11. What will happen in this code?

         int a = 100, b = 200;

         int *p = &a, *q = &b;

         p = q;

  12. A.
    b is assigned to a
    B.
    p now points to b
    C.
    a is assigned to b
    D.
    q now points to a

    View Answer

    Workspace

    Discuss Discuss in Forum


  13. What is the output of this program?

    #include < iostream >

    using namespace std;

    int main()

    {

    int a = 5, b = 10, c = 15;

    int *arr[ ] = {&a, &b, &c};

    cout << arr[1];

    return 0;

    }

  14. A.
    5
    B.
    10
    C.
    15
    D.
    it will return some random number

    View Answer

    Workspace

    Discuss Discuss in Forum


  15. The correct statement for a function that takes pointer to a float, a pointer to a pointer to a char and returns a pointer to a pointer to a integer is
  16. A.
    int **fun(float**, char**)
    B.
    int *fun(float*, char*)
    C.
    int ***fun(float*, char**)
    D.
    int ***fun(*float, **char)

    View Answer

    Workspace

    Discuss Discuss in Forum


  17. What is the output of this program?

    #include < iostream >

    using namespace std;

    int main()

    {

    char arr[20];

    int i;

    for(i = 0; i < 10; i++)

    *(arr + i) = 65 + i;

    *(arr + i) = '\0';

    cout << arr;

    return(0);

    }

  18. A.
    ABCDEFGHIJ
    B.
    AAAAAAAAAA
    C.
    JJJJJJJJ
    D.
    none of the mentioned

    View Answer

    Workspace

    Discuss Discuss in Forum


  19. What is the output of this program?

    #include < iostream >

    using namespace std;

    int main()

    {

    char *ptr;

    char Str[] = "abcdefg";

    ptr = Str;

    ptr += 5;

    cout << ptr;

    return 0;

    }


  20. A.
    fg
    B.
    cdef
    C.
    defg
    D.
    abcd

    View Answer

    Workspace

    Discuss Discuss in Forum