find the output of the following program
main()
{
int x=5, *p;
p=&x;
printf("%d",++*p);
}
Answers were Sorted based on User's Feedback
Answer / rahul khare
6
becoz it(++*p) will evaluate like this-
1)
*(p)- gives value at this address that is 5
2)
now increment ++5
that is 6.
Is This Answer Correct ? | 37 Yes | 1 No |
Answer / vignesh1988i
the answer is 6...since ++ as well as * gets the same
prority so the associativity will be right to left.. so it
will point to the value and then increment the value
Is This Answer Correct ? | 23 Yes | 3 No |
Answer / manishsoni
main()
{
int x=5, *p;
p=&x;
printf("%d",++*p);
}
it allocate as this
____ _____
x| |value p | | store &x
| 5 | | 100 |
|____| |_____|
____ _____
|100 |&x | 200 |&p p is pointer //at statement ++*p
|____| |_____|
^ ^
|________________|
and jumpt at 5 bcoz it is prefix for firstof all 5 is
increase then print
Is This Answer Correct ? | 7 Yes | 2 No |
What is fflush() function?
what is the output of the following program? #include<stdio.h> void main() { int x=4,y=3,z; z=x-- -y; printf("\n%d %d %d",x,y,z); }
What do you mean by c?
Can we add pointers together?
Are the expressions * ptr ++ and ++ * ptr same?
1.write a program to merge the arrays 2.write efficient code for extracting unique elements from a sorted list of array?
CopyBits(x,p,n,y) copy n LSBs from y to x starting LSB at 'p'th position.
i=20,k=0; for(j=1;j<i;j=1+4*(i/j)) { k+=j<10?4:3; } printf("%d", k);
How can you read a directory in a C program?
what is difference b/w extern & volatile variable??
What is define c?
What is the ANSI C Standard?