Home / General Knowledge / Testing New :: Pointer MCQs

General Knowledge :: Testing New

  1. Determine Output:

    void main()

    {

    char far *farther, *farthest;

    printf("%d..%d", sizeof(farther), sizeof(farthest));

    }

  2. A.

     4..2

    B.

     2..2

    C.

     4..4

    D.

     2..4

    View Answer

    Workspace

    Discuss Discuss in Forum


  3. Determine Output:

    main()

    {

    char *str1 = "abcd";

    char str2[] = "abcd";

    printf("%d %d %d", sizeof(str1), sizeof(str2), sizeof("abcd"));

    }

  4. A.

     2 5 5

    B.

     2 4 4

    C.

     8 5 5

    D.

     2 4 5

    View Answer

    Workspace

    Discuss Discuss in Forum


  5. Choose the best answer.
    Prior to using a pointer variable

  6. A.

     It should be declared.

    B.

     It should be initialized.

    C.

     It should be both declared and initialized.

    D.

     None of these.

    View Answer

    Workspace

    Discuss Discuss in Forum


  7. Comment on the following pointer declaration?

    int *ptr, p;

  8. A.

     ptr is a pointer to integer, p is not.

    B.

     ptr and p, both are pointers to integer.

    C.

     ptr is pointer to integer, p may or may not be.

    D.

     ptr and p both are not pointers to integer.

    View Answer

    Workspace

    Discuss Discuss in Forum


  9. What will be the output?

    main()

    {

    char *p;

    p = "Hello";

    printf("%cn",*&*p);

    }

  10. A.

     Hello

    B.

     H

    C.

     Some address will be printed

    D.

     None of these.

    View Answer

    Workspace

    Discuss Discuss in Forum


  11. Determine output:

    #include <stdio.h>

    void main()

    {

    char *p = NULL;

    char *q = 0;

    if(p)

    printf(" p ");

    else

    printf("nullp");

    if(q)

    printf("q");

    else

    printf(" nullq");

    }

  12. A.

     p q

    B.

     Depends on the compiler

    C.

     x nullq where x can be p or nullp depending on the value of NULL

    D.

     nullp nullq

    View Answer

    Workspace

    Discuss Discuss in Forum


  13. The address operator &, cannot act on

  14. A.

     R-values

    B.

     Arithmetic expressions

    C.

     Both of the above

    D.

     Local variables

    E.

     Members of a structure

    View Answer

    Workspace

    Discuss Discuss in Forum


  15. The statement int **a;

  16. A.

     is illegal

    B.

     is legal but meaningless

    C.

     is syntactically and semantically correct

    D.

     None of these.

    View Answer

    Workspace

    Discuss Discuss in Forum


  17. What will be the output of the following program?

    #include<stdio.h>

    void main()

    {

    int i = 10;

    void *p = &i;

    printf("%d\n", (int)*p);

    }

  18. A.

     Compiler time error

    B.

     Segmentation fault/runtime crash

    C.

     10

    D.

     Undefined behavior

    View Answer

    Workspace

    Discuss Discuss in Forum


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

    #include<stdio.h>

    void main()

    {

    int i = 10;

    void *p = &i;

    printf("%f", *(float *)p);

    }

  20. A.

     Error

    B.

     10

    C.

     0.000000

    D.

     None of these.

    View Answer

    Workspace

    Discuss Discuss in Forum