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

Was 2000 a leap year?

0 Answers  


Add Two Numbers Without Using the Addition Operator

0 Answers  


What will happen when freeing memory twice

2 Answers  


What is the output for the program given below typedef enum grade{GOOD,BAD,WORST,}BAD; main() { BAD g1; g1=1; printf("%d",g1); }

4 Answers   ADITI,


wat is output of the following int main() { const int j=2; int i; switch(i) { case 1:break; case j:break; default:break; } }

2 Answers  






How to add two numbers with using function?

4 Answers  


What is non linear data structure in c?

0 Answers  


Explain the ternary tree?

0 Answers  


At a shop of marbles, packs of marbles are prepared. Packets are named A, B, C, D, E …….. All packets are kept in a VERTICAL SHELF in random order. Any numbers of packets with these names could be kept in that shelf as in this example: bottom of shelf ---> [AAAJKRDFDEWAAYFYYKK]-----Top of shelf. All these packets are to be loaded on cars. The cars are lined in order, so that the packet could be loaded on them. The cars are also named [A, B, C, D, E,………….]. Each Car will load the packet with the same alphabet. So, for example, car ‘A’ will load all the packets with name ‘A’. Each particular car will come at the loading point only once. The cars will come at the loading point in alphabetical order. So, car ‘B’ will come and take all the packets with name ‘B’ from the shelf, then car ‘C’ will come. No matter how deep in the shelf any packet ‘B’ is, all of the ‘B’ packets will be displaced before the ‘C’ car arrives. For that purpose, some additional shelves are provided. The packets which are after the packet B, are kept in those shelves. Any one of these shelves contains only packets, having the same name. For example, if any particular shelf is used and if a packet with name X is in it, then only the packets having names X will be kept in it. That shelf will look like [XXXXXXX]. If any shelf is used once, then it could be used again only if it is vacant. Packets from the initial shelf could be unloaded from top only. Write a program that finds the minimum total number of shelves, including the initial one required for this loading process.

0 Answers   Infosys,


how can be easily placed in TCS.

0 Answers   TCS,


what is a non volatile key word in c language?

1 Answers  


What is the difference between malloc calloc and realloc in c?

0 Answers  


Categories