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

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

  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

  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

  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;

  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

  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

  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)

  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

  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