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

CSE MCQs :: C-MCQs

  1. What is the output of the code below?

    int main()
    {
    int i = 10;
    int *const p = &i;
    foo(&p);
    printf("%d\n", *p);
    }
    void foo(int **p)
    {
    int j = 11;
    *p = &j;
    printf("%d\n", **p);
    }
  2. A.
    11   11
    B.
    Undefined behaviour
    C.
    Compile time error
    D.
    Segmentation fault/code-crash

    View Answer

    Workspace

    Discuss Discuss in Forum


  3. Which of the following are correct syntaxes to send an array as a parameter to function:
  4. A.
    func(&array);
    B.
    func(array);
    C.
    func(*array);
    D.
    func(array[size]);

    View Answer

    Workspace

    Discuss Discuss in Forum


  5. What is the output of this C code?

    void main()
    {
    int k = 5;
    int *p = &k;
    int **m = &p;
    printf("%d%d%d\n", k, *p, **m);
    }
  6. A.
    5   5   5
    B.
    5  5 junk value
    C.
    5 junk value
    D.
    Run time error

    View Answer

    Workspace

    Discuss Discuss in Forum


  7. What is the output of this C code?

    void main()
    {
    int k = 5;
    int *p = &k;
    int **m = &p;
    printf("%d%d%d\n", k, *p, **p);
    }
  8. A.
    5  5  5
    B.
    5  5 junk value
    C.
    5 junk value
    D.
    Compile time error

    View Answer

    Workspace

    Discuss Discuss in Forum


  9. What is the output of this C code?

    void
    main()
    {
    int k = 5;
    int *p = &k;
    int **m = &p;
    **m = 6;
    printf("%d\n", k);
    }
  10. A.
    5
    B.
    Compile time error
    C.
    6
    D.
    Junk

    View Answer

    Workspace

    Discuss Discuss in Forum


  11. What is the output of this C code?

    void main()
    {
    int a[3] = {1, 2, 3};
    int *p = a;
    int *r = &p;
    printf("%d", (**r));
    }
  12. A.
    1
    B.
    Compile time error
    C.
    Address of a
    D.
    Junk value

    View Answer

    Workspace

    Discuss Discuss in Forum


  13. What is the output of this C code?

    void main()
    {
    int a[3] = {1, 2, 3};
    int *p = a;
    int **r = &p;
    printf("%p %p", *r, a);
    }
  14. A.
    Different address is printed
    B.
    1   2
    C.
    Same address is printed.
    D.
    1   1

    View Answer

    Workspace

    Discuss Discuss in Forum


  15. How many number of pointer (*) does C have against a pointer variable declaration?
  16. A.
    7
    B.
    127
    C.
    255
    D.
    No limits

    View Answer

    Workspace

    Discuss Discuss in Forum


  17. What is the output of this C code?

    int main()
    {
    int a = 1, b = 2, c = 3;
    int *ptr1 = &a, *ptr2 = &b, *ptr3 = &c;
    int **sptr = &ptr1; //-Ref
    *sptr = ptr2;
    }
  18. A.
    ptr1 points to a
    B.
    ptr1 points to b
    C.
    sptr points to ptr2
    D.
    None of the mentioned.

    View Answer

    Workspace

    Discuss Discuss in Forum


  19. What is the output of this C code?

    void main()
    {
    int a[3] = {1, 2, 3};
    int *p = a;
    int **r = &p;
    printf("%p %p", *r, a);
    }
  20. A.
    Different address is printed
    B.
    1   2
    C.
    Same address is printed.
    D.
    1   1

    View Answer

    Workspace

    Discuss Discuss in Forum