Pointers


  1. What will be the output of the following C code?
    #include <stdio.h>
    int main()
    {
    int A[5] = {10, 20, 30, 40, 50};
    int *ptr = A + 2;
    printf("%d %d\n", ptr[-1], A[*ptr]);
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: A

    20 0


  1. What will be the output of the following C code?
     #include <stdio.h>
    int main()
    {
    int array[5] = {11, 12, 13, 14, 15};
    int *ptr = array + 7;
    printf("%d\n", ptr[-3]);
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: E

    15



  1. What will be the output of the following C code?
    #include <stdio.h>
    void fun( int[] );
    int main()
    {
    int array[5] = {10, 20, 30, 40, 50};
    fun(array);
    printf("%d ", array[2]);
    }
    void fun(int ptr[5])
    {
    int n = 100;
    ptr = &n;
    printf("%d ", ptr[0]);
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: E

    100 30


  1. What will be the output of the following C code?
    #include <stdio.h>
    void main()
    {
    char *str= "WATCH";
    char *ptr = str;
    printf("%c %c", 1[ptr], str[1]);
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: A

    A A



  1. What will be the output of the following C code?
     #include <stdio.h>
    void main()
    {
    char *str= "WELCOME";
    char *ptr = str;
    printf("%c %c", *(ptr + 2), str[0]);
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    L W