Find Output Of Program

Question 11 :

What will be the output of the program?

#include < stdio.h >
int main()
{
    int arr[2][2][2] = {10, 2, 3, 4, 5, 6, 7, 8};
    int *p, *q;
    p = &arr[1][1][1];
    q = (int*) arr;
    printf("%d, %d\n", *p, *q);
    return 0;
}


A). 8, 10
B). 10, 2
C). 8, 1
D). Garbage values
Answer : Option A

Question 12 :

What will be the output of the program assuming that the array begins at the location 1002 and size of an integer is 4 bytes?

#include < stdio.h >
int main()
{
    int a[3][4] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 };
    printf("%u, %u, %u\n", a[0]+1, *(a[0]+1), *(*(a+0)+1));
    return 0;
}


A). 448, 4, 4
B). 520, 2, 2
C). 1006, 2, 2
D). Error
Answer : Option C

Question 13 :

13. What will be the output of the program?

#include < stdio.h >
int main()
{
    int arr[3] = {2, 3, 4};
    char *p;
    p = arr;
    p = (char*)((int*)(p));
    printf("%d, ", *p);
    p = (int*)(p+1);
    printf("%d", *p);
    return 0;
}


A). 2, 3
B). 2, 0
C). 2, Garbage value
D). 0, 0
Answer : Option B

Question 14 :

What will be the output of the program ?

#include < stdio.h >
int main()
{
    char *str;
    str = "%d\n";
    str++;
    str++;
    printf(str-2, 300);
    return 0;
}


A). No output
B). 30
C). 3
D). 300
Answer : Option D

Question 15 :

What will be the output of the program ?

#include < stdio.h >
int main()
{
    printf("%c\n", 7["IndiaPAR"]);
    return 0;
}


A). Error: in printf
B). Nothing will print
C). print "R" of IndiaPAR
D). print "7"
Answer : Option C