1. 

What will be the output of the program ?

#include<stdio.h>

int main()
{
    void *vp;
    char ch=74, *cp="JACK";
    int j=65;
    vp=&ch;
    printf("%c", *(char*)vp);
    vp=&j;
    printf("%c", *(int*)vp);
    vp=cp;
    printf("%s", (char*)vp+2);
    return 0;
}


A. JCK
B. J65K
C. JAK
D. JACK

Answer: Option D

Explanation:

Pointer always store integer value so cp will store the memory address of location where string "jack " is stored.

Step 1 : vp = &ch;
/*Will store address of ch in vp so while we print content in printf it will print asccii value of 74 i.e "J"*/

Step 2 : vp = &j;
/* It will assign address of j to vp again it will print ascii value of 65 as "A"*/

Step 3 : vp = cp;
/* In this step cp is pointing to memory locatioon where string jack is stored and we r incrementing it by two so it will point to "C" from sring "JACK" and since we hava given %S in printf so it will print content from c onwords ie "CK"*/

So final combined output will be JACK.