Pointers


  1. What will be the output of the following C code?
    #include <stdio.h>
    void main()
    {
    int n = 0;
    int *p = &n;
    printf("%p\n", p);
    p++;
    printf("%p\n ", p);
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: B

    0x7ffc391e1404
    0x7ffc391e1408


  1. What will be the output of the following C code?
    #include <stdio.h>
    void main()
    {
    int var = 10;
    int *p = &15;
    printf("%p\n", p);
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    Compilation Error

    main.c: In function ‘main’:
    main.c:5:18: error: lvalue required as unary ‘&’ operand
    int *p = &15;



  1. What will be the output of the following C code?
    #include <stdio.h>
    void main()
    {
    int var = 101;
    int *p = &var;
    printf("%d\n", *p);
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: A

    101


  1. What will be the output of the following C code?
    #include <stdio.h>
    void fun(int*);
    int main()
    {
    int n = 14, *ptr = &n;
    fun(ptr++);
    }
    void fun(int *ptr)
    {
    printf("%d\n", *ptr);
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: A

    0.000000



  1. What will be the output of the following C code?
     #include <stdio.h>
    int main()
    {
    int n = 58, *ptr = &n;
    function(&ptr);
    printf("%d ", *ptr);
    return 0;
    }
    void function(int **ptr)
    {
    int k = 12;
    *ptr = &k;
    printf("%d ", **ptr);
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    12 12