Pointers


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











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    Compilation Error



  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



  1. What will be the output of the following C code?
    #include <stdio.h>
    int main()
    {
    int num = 45, *ptr = #
    function(&num);
    printf("%d ", *ptr);
    }
    void function(int *ptr)
    {
    int L = 20;
    ptr = &L;
    printf("%d ", *ptr);
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: A

    20 45


  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>
    void fun(int*);
    int main()
    {
    int n = 101, *ptr = &n;
    fun(ptr++);
    }
    void fun(int *ptr)
    {
    printf("%d\n", *ptr);
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: B

    101