What's the output of this C program?
main()
{
int *ptr=(int*)malloc(sizeof(int));
*ptr=4;
printf("%d",(*ptr)+++*ptr++);
{
int *ptr=(int*)malloc(sizeof(int));
*ptr=4;
printf("%d",(*ptr)+++*ptr++);
Replies
-
Kaustubh KatdareI added a better title to the question. I think you're asking about the output of this program, right? Why not just run it and check for yourself?
-
rahul69
It will print 8,bhulaxmimain()
{
int *ptr=(int*)malloc(sizeof(int));
*ptr=4;
printf("%d",(*ptr)+++*ptr++);
After the printf statement is executed, the pointer ptr had move to next address, and the value at earlier address is incremented (ie, becomes 5), if u still got any doubts, plz do share 😀 -
Nayan GoenkaI think this program will generate output 10. Still working on it. Will give a definite output once I execute it on my side. But I guess you already know that this function is not just complete program. It needs prototypes or header files to run.
You are reading an archived discussion.
Related Posts
I am currently doing Undergraduate Course in E&TC 3rd year in Pune
which language should I study any programming language ..
objective c and python are good option since I...
Hey.
Now that I am a proud member of the engineering workforce of India, I find my old '08 blackberry becoming more obsolescent by the day. I am in the...
Well i just observed that i m getting some trophies for my post count and ratings. Can anyone tell me the criteria for advancing to the next level. I saw...
I read on Wikipedia that each country has its own 'Engineers Day'. In India, engineers day is celebrated on September 15th. I thought of compiling a huge collection of "Happy...
We feel incredibly awesome while writing this post and promise that once you're done reading it, you'll feel awesome too. Knowing that even the fastest of the supercomputers in the...