int arr[] = {1,2,3,4}
int *ptr=arr;
*(arr+3) = *++ptr + *ptr++;
Final contents of arr[]
Answer Posted / 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 |
Post New Answer View All Answers
main() { struct s1 { char *str; struct s1 *ptr; }; static struct s1 arr[] = { {"Hyderabad",arr+1}, {"Bangalore",arr+2}, {"Delhi",arr} }; struct s1 *p[3]; int i; < BR> for(i=0;i<=2;i++) p[i] = arr[i].ptr; printf("%s ",(*p)->str); printf("%s ",(++*p)->str); printf("%s ",((*p)++)->str); }
Difference between constant pointer and pointer to a constant.
What is the use of parallelize in spark?
please explain clearly about execution of c program in detail,in which stage are the printf sacnf getting into exeecutable code
What is a example of a variable?
How can I get random integers in a certain range?
Explain the difference between structs and unions in c?
What does the format %10.2 mean when included in a printf statement?
When c language was developed?
write a program to display all prime numbers
Why we use int main and void main?
What is pointer to pointer in c?
In a switch statement, what will happen if a break statement is omitted?
What is derived datatype in c?
what is the structure pointer?