C Programming - Pointers - Discussion
Discussion Forum : Pointers - Find Output of Program (Q.No. 3)
3.
What will be the output of the program ?
#include<stdio.h>
int main()
{
int x=30, *y, *z;
y=&x; /* Assume address of x is 500 and integer is 4 byte size */
z=y;
*y++=*z++;
x++;
printf("x=%d, y=%d, z=%d\n", x, y, z);
return 0;
}
Discussion:
92 comments Page 9 of 10.
Singh said:
1 decade ago
x = 30.
x++ = 31.
And z++ = 500+sizeof(int) = 504.
Same as y = 504.
x++ = 31.
And z++ = 500+sizeof(int) = 504.
Same as y = 504.
Gururaj said:
1 decade ago
@Kishore Mylavarapu
Yes explanation is very good I agree
Thanks.
Yes explanation is very good I agree
Thanks.
Shobhit Kumar said:
9 years ago
On compiling the answer came as x = 31, y = 2293104, z = 2293104.
Amit_Nawale said:
1 decade ago
*y++=*z++ is explicitly written as
*y = *z;
y++;
z++;
*y = *z;
y++;
z++;
Devanshmody said:
1 decade ago
500 is memory address and space occupied is 4bytes.
Tpr said:
8 years ago
*y++=*z++;.
Is above statement means 504=504?
Is above statement means 504=504?
(2)
Rk balaji said:
1 decade ago
@cp verma.
You didn't explain the difference?
You didn't explain the difference?
Pandey said:
1 decade ago
Concept:.
++ has greater precedence then *.
++ has greater precedence then *.
Pallvi said:
10 years ago
Why post incr returning incremented value?
Akhilesh singh said:
1 decade ago
Given x=30
and x+1=x++
s0 x++=30+1=31;
and x+1=x++
s0 x++=30+1=31;
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers