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



int arr[] = {1,2,3,4} int *ptr=arr; *(arr+3) = *++ptr + *ptr++; Final contents of ar..

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

int arr[] = {1,2,3,4} int *ptr=arr; *(arr+3) = *++ptr + *ptr++; Final contents of ar..

Answer / guest

{1,2,3,4}

Is This Answer Correct ?    10 Yes 4 No

int arr[] = {1,2,3,4} int *ptr=arr; *(arr+3) = *++ptr + *ptr++; Final contents of ar..

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

int arr[] = {1,2,3,4} int *ptr=arr; *(arr+3) = *++ptr + *ptr++; Final contents of ar..

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

int arr[] = {1,2,3,4} int *ptr=arr; *(arr+3) = *++ptr + *ptr++; Final contents of ar..

Answer / sachin

1 2 3 3

Is This Answer Correct ?    1 Yes 6 No

int arr[] = {1,2,3,4} int *ptr=arr; *(arr+3) = *++ptr + *ptr++; Final contents of ar..

Answer / vignesh1988i

1 2 3 5

Is This Answer Correct ?    2 Yes 10 No

Post New Answer

More C Interview Questions

could u able to tell about suresoft technical session

1 Answers  


what is the output of the following code? main() { int I; I=0x10+010+10; printf("x=%x",I); } give detailed reason

3 Answers  


How to set file pointer to beginning c?

0 Answers  


Is main() function predfined or userdefined?

11 Answers  


When is a void pointer used?

0 Answers  






What is struct node in c?

0 Answers  


Explain is it better to use a pointer to navigate an array of values, or is it better to use a subscripted array name?

0 Answers  


Explain is it better to bitshift a value than to multiply by 2?

0 Answers  


What is the output of the following progarm? #include<stdio.h> main( ) { int x,y=10; x=4; y=fact(x); printf(“%d\n”,y); } unsigned int fact(int x) { return(x*fact(x-1)); } A. 24 B. 10 C. 4 D. none

2 Answers  


what is mallloc()?how it works?

4 Answers   Excel,


What is spark map function?

0 Answers  


What are the languages are portable and platform independent?Why they are like that?

1 Answers   Excel, Satyam,


Categories