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;
}
Discussion:
84 comments Page 3 of 9.
Krishnaveni said:
8 years ago
Thanks for your explanation @Nilesh.
Pradeepa said:
8 years ago
Till now, I didn't clear please explain in short and clear.
(2)
Navya said:
8 years ago
Thanks.
(1)
Imran ahmad said:
8 years ago
Thanks @Nilesh.
(1)
Agii said:
8 years ago
Thanks @Nilesh.
(1)
Shubham said:
8 years ago
@Sriram.
Because there is %c format specifier in the printf function.
Because there is %c format specifier in the printf function.
Sivaraj MCA said:
8 years ago
The void pointer can't accept any arithmetic operation then how it is possible?
Sriram said:
9 years ago
In the 9th line it is integer type casting how 'A' is displayed.
Sai kumar said:
9 years ago
Thank you @Nilesh.
Sumit said:
9 years ago
Super job, Thank you @Nilesh.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers