Find Output Of Program

Question 16 :

What will be the output of the program ?

#include < stdio.h >
int main()
{
    char str[] = "peace";
    char *s = str;
    printf("%s\n", s++ +3);
    return 0;
}


A). peace
B). eace
C). ace
D). ce
Answer : Option D

Question 17 :

What will be the output of the program ?

#include < stdio.h >
int main()
{
    char *p;
    p="hello";
    printf("%s\n", *&*&p);
    return 0;
}


A). llo
B). hello
C). ello
D). h
Answer : Option B

Question 18 :

What will be the output of the program assuming that the array begins at location 1002?

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


A). 1002, 2004, 4008, 2
B). 2004, 4008, 8016, 1
C). 1002, 1002, 1002, 1
D). Error
Answer : Option C

Question 19 :

What will be the output of the program ?

#include < stdio.h >
power(int**);
int main()
{
    int a=5, *aa; /* Address of 'a' is 1000 */
    aa = &a;
    a = power(&aa);
    printf("%d\n", a);
    return 0;
}
power(int **ptr)
{
    int b;
    b = **ptr***ptr;
    return (b);
}


A). 5
B). 25
C). 125
D). Garbage value
Answer : Option B

Question 20 :

What will be the output of the program ?

#include < stdio.h >
int main()
{
    char str1[] = "India";
    char str2[] = "PAR";
    char *s1 = str1, *s2=str2;
    while(*s1++ = *s2++)
        printf("%s", str1);

    printf("\n");
    return 0;
}


A). IndiaPAR
B). PndiaPAdiaPARia
C). India
D). (null)
Answer : Option B