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 will be the output of "printf("%d%d",scanf("%d% d",&a,&b))".provide an explation regarding the question
what is the role you expect in software industry?
what is difference between array,strutter,union and pointers
3 Answers CTS, Lovely Professional University, Mannar Company,
explain how do you use macro?
Why c is called top down?
What is the difference between declaring a variable by constant keyword and #define ing that variable?
Why doesn't C have nested functions?
To what value are pointers initialized? 1) NULL 2) Newly allocated memory 3) No action is taken by the compiler to initialize pointers.
ABCDCBA ABC CBA AB BA A A
How can I avoid the abort, retry, fail messages?
What is main () in c?
How to add two numbers with using function?