int arr[] = {1,2,3,4}
int *ptr=arr;
*(arr+3) = *++ptr + *ptr++;
Final contents of arr[]
Answers were Sorted based on User's Feedback
Answer / jai
{1,2,3,4}
++ has higher precedence over *, assigment will resolve to
*(arr+3) = *(++ptr) + *(ptr++);
*(arr+3) = 2 + 2;
=> Though ptr is pointing to address of 3rd element after
post increment.
| Is This Answer Correct ? | 13 Yes | 1 No |
Answer / anag
*(arr+3)------>arr[0][3] that means the there is any chnage
in the last value of an array
{1,2,3,--}
we know ++ has higher prededence than * so
*++ptr---->*(++ptr)
*(++ptr)----> increment in the location after that it point
to the value
it represent the second location of an array
* represent the value at this address
the value at the second location is 2.
in the second expression first it refer the value after
that it increment in the location
ptr currently points to the second location . ptr holds
that location for the second expression * represent the
value at that location that is 2.
so 2+2->4
{1,2,3,4} ----------->ans
suppose if we add a another expression after this that *ptr
then it print the value 3
because previous expression increment the location of the
value
Thank you
| Is This Answer Correct ? | 5 Yes | 0 No |
Answer / vijaisankar
In this statement
first ptr holds base address of the array(4000),
then as per precedence operators ptr gets post incremented
(4002)though it points the value 1(4000)(ptr is post
incremented) and then ptr gets preincrement so (4004) the
value in that one is 3 then 3+1=4.
*(arr+3)=3;
| Is This Answer Correct ? | 2 Yes | 7 No |
class foo { public: static int func(const char*& p) const; }; This is illegal, why?
i have a written test in tomorrow
Can we declare a function inside a function in c?
What is double pointer in c?
DIFFERNCE BETWEEN THE C++ AND C LANGUAGE?
what is the difference between static variable and register variable?
What is the difference between fread and fwrite function?
When reallocating memory if any other pointers point into the same piece of memory do you have to readjust these other pointers or do they get readjusted automatically?
void main() { int a=1; while(a++<=1) while(a++<=2); }
Differentiate between full, complete & perfect binary trees.
Write a program to display all the prime nos from 1 to 1000000, your code should not take time more than a minute to display all the nos.
Write a program to use switch statement.
0 Answers Agilent, Integreon, ZS Associates,