Home / General Knowledge / Testing New :: Pointer MCQs

General Knowledge :: Testing New

  1. The operator > and < are meaningful when used with pointers, if

  2. A.

     The pointers point to data of similar type.

    B.

     The pointers point to structure of similar data type.

    C.

     The pointers point to elements of the same array.

    D.

     None of these.


  3. The declaration
    int (*p) [5];
    means

  4. A.

     p is one dimensional array of size 5, of pointers to integers.

    B.

     p is a pointer to a 5 elements integer array.

    C.

     The same as int *p[

    D.

     None of these.


  5. Comment on the following?
    const int *ptr;

  6. A.

     We cannot change the value pointed by ptr.

    B.

     We cannot change the pointer ptr itself.

    C.

     Both of the above

    D.

     We can change the pointer as well as the value pointed by it.


  7. #include<stdio.h>

    void main()

    {

    int *ptr, a=10;

    ptr = &a;

    *ptr += 1;

    printf("%d, %d", *ptr, a);

    }

  8. A.

     10, 10

    B.

     10, 11

    C.

     11, 10

    D.

     11, 11


  9. A function 'p' that accepts a pointer to a character as argument and returns a pointer to an array of integer can be declared as

  10. A.

     int(*p(char *))[]

    B.

     int *p(char *)[]

    C.

     int (*p) (char *)[]

    D.

     None of these.


  11. What will be printed after compiling and running the following code?

    main()

    {

    char *p;

    printf("%d %d",sizeof(*p), sizeof(p));

    }

  12. A.

     1 1

    B.

     1 2

    C.

     2 1

    D.

     2 2


  13. What will be the output of the following program code?

    #include <stdio.h>

    void main()

    {

    int i=3, *j, **k;

    j = &i;

    k = &j;

    printf("%d%d%d", *j, **k, *(*k));

    }

  14. A.

     444

    B.

     000

    C.

     333

    D.

     433

    E.

     Garbage Value


  15. Which of the following is the correct way of declaring a float pointer:

  16. A.

     float ptr;

    B.

     float *ptr;

    C.

     *float ptr;

    D.

     None of the above


  17. Find the output of the following program.

    void main()

    {

    char *msg = "hi";

    printf(msg);

    }

  18. A.

     hi

    B.

     h

    C.

     hi followed by garbage value

    D.

     Error

    E.

     Garbage Value


  19. Find the output of the following program.

    void main()

    {

    int array[10];

    int *i = &array[2], *j = &array[5];

    int diff = j-i;

    printf("%d", diff);

    }

  20. A.

     3

    B.

     6

    C.

     Garbage value

    D.

     Error