main()
{
int *ptr=(int*)malloc(sizeof(int));
*ptr=4;
printf("%d",(*ptr)+++*ptr++);
}
Answers were Sorted based on User's Feedback
Ans = 8
Explanation:
after brackets post increment has higher precedence,
hence expression can be viewed as
(*ptr)++ + *ptr++
printf("%d",(*ptr)+++*ptr++); can be expanded in 3 steps as
1. printf("%d",(*ptr)+*ptr); => displays 4+4
2. ptr++; => increments the pointer to next location
3. (*ptr)++; => increments the value in that location
This program can be better understood, with the below modification
main()
{
int *ptr=(int*)malloc(sizeof(int)*2);
*ptr=4; // current location value = 4
*(ptr+1) = 10; // next location value = 10
printf("%d\n",(*ptr)+++*ptr++); // display 8 (4+4)
printf("%d\n",*(ptr-1)); // current location value = 4
printf("%d\n",*ptr); // next location value = 10+1 = 11
}
| Is This Answer Correct ? | 3 Yes | 3 No |
Answer / abhishek
(*ptr)++ = 5
(*ptr)++ = 5
(*ptr)+++(*ptr)++ = 5 + 5 = 10
| Is This Answer Correct ? | 0 Yes | 2 No |
Which is an example of a structural homology?
WHY DO WE USE A TERMINATOR IN C LANGUAGE?
What is volatile in c language?
how to print the character with maximum occurence and print that number of occurence too in a string given ?
What is the use of f in c?
What is the use of a semicolon (;) at the end of every program statement?
How can I swap two values without using a temporary?
Can U write a C-program to print the size of a data type without using the sizeof() operator? Explain how it works inside ?
An expression to whose value an operater is applied a) operand b) variable c) constant d) all of the above
main() { enum _tag{ left=10, right, front=100, back}; printf("%d, %d, %d, %d", left, right, front, back); }
Hi Every one......... Please Any body give me the answer for my question. Is it possible to print the word "PRINT F", without using printf() statement in C-Language.
What is your stream meaning?