Home / General Knowledge / Testing New :: Pointer MCQs

General Knowledge :: Testing New

  1. Find the output of the following program.

    void main()

    {

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

    }

  2. A.

     2, 0

    B.

     0, 2

    C.

     2, 2

    D.

     2, 4

    E.

     4, 4


  3. Find the output of the following program.

    void main()

    {

    int i=10; /* assume address of i is 0x1234ABCD */

    int *ip=&i;

    int **ipp=&&i;

    printf("%x,%x,%x", &i, ip, *ipp);

    }

  4. A.

     0x1234ABCD, 0x1234ABCD, 10

    B.

     0x1234ABCD, 0x1234ABCD, 0x1234ABCD

    C.

     0x1234ABCD, 10, 10

    D.

     Syntax error

    E.

     Runtime error


  5. Which of the following statements are true after execution of the program.

    void main()

    {

    int a[10], i, *p;

    a[0] = 1;

    a[1] = 2;

    p = a;

    (*p)++;

    }

  6. A.

     a[1] = 3

    B.

     a[0] = 2

    C.

     a[1] = 2

    D.

     a[0] = 3

    E.

     Compilation error


  7. What is the base data type of a pointer variable by which the memory would be allocated to it?

  8. A.

     int

    B.

     float

    C.

     No data type

    D.

     Depends upon the type of the variable to which it is pointing.

    E.

     unsigned int


  9. What would be the output for the following Turbo C code?

    #include<stdio.h>

    void main()

    {

    int a[]={ 1, 2, 3, 4, 5 }, *p;

    p=a;

    ++*p;

    printf("%d ", *p);

    p += 2;

    printf("%d", *p);

    }

  10. A.

     2 4

    B.

     3 4

    C.

     2 2

    D.

     2 3

    E.

     3 3


  11. char* myfunc(char *ptr)

    {

    ptr+=3;

    return(ptr);

    }

    void main()

    {

    char *x, *y;

    x = "EXAMVEDA";

    y = myfunc(x);

    printf("y=%s", y);

    }

    What will be printed when the sample code above is executed?

  12. A.

     y=EXAMVEDA

    B.

     y=AMVEDA

    C.

     y=MVEDA

    D.

     y=VEDA

    E.

     y=EDA


  13. char *ptr;

    char myString[] = "abcdefg";

    ptr = myString;

    ptr += 5;

    what string does ptr point to in the sample code above?

  14. A.

     fg

    B.

     efg

    C.

     defg

    D.

     cdefg

    E.

     bcdefg