Pointers


  1. What will be the output of the following C code?
    #include <stdio.h>
    int main()
    {
    int *ptr1 = (int *)4;
    int *ptr2 = (int *)6;
    printf("%d", ptr1 + ptr2);
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    Compilation Error

    main.c: In function ‘main’:
    main.c:6:27: error: invalid operands to binary + (have ‘int *’ and ‘int *’)
    printf("%d", ptr1 + ptr2);


  1. What will be the output of the following C code?
    #include <stdio.h>
    int main()
    {
    double *p = (double *)150;
    p = p + 5;
    printf("%u", p);
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: E

    190



  1. What will be the output of the following C code?
     #include <stdio.h>
    int main()
    {
    int num[5] = {11, 21, 31, 41, 51};
    int ptr[5];
    ptr = num;
    printf("%d\n", ptr[2]);
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    Compilation Error

    main.c: In function ‘main’:
    main.c:6:13: error: assignment to expression with array type
    ptr = num;


  1. Comment on an array of the void data type.











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    You cannot have an array of void data type



  1. An array of similar data types which themselves are a collection of dissimilar data type are ___________.











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: B

    Array of Structure