C Programming - Pointers - Discussion

Discussion Forum : Pointers - Find Output of Program (Q.No. 10)
10.
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;
}
JCK
J65K
JAK
JACK
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
84 comments Page 3 of 9.

Neel Purohit said:   9 years ago
@Nilesh.

Thank you for the brilliant answer and simple explanation.

Sriram said:   9 years ago
In the 9th line it is integer type casting how 'A' is displayed.

Abdul said:   3 weeks ago
@Nilesh.

Thank you very much, you explained it very clearly.

Pradeepa said:   8 years ago
Till now, I didn't clear please explain in short and clear.
(2)

Lucky said:   1 decade ago
ch is character variable then hw would we assign it to 74?

Akash said:   9 years ago
@Nilesh.

Thank you very mush. Your explanation is clear.

Ask said:   9 years ago
Thanks @Nilesh. Your concept is clear to understnd.

Umamahesh said:   1 decade ago
Really fantastic explanation by nilesh good job.

Saurabh said:   10 years ago
How to convert those numbers in ASCII values?

Lokesh said:   1 decade ago
@Arun.

Great explanation. Finally I got it!


Post your comments here:

Your comments will be displayed after verification.