retagged by
1,079 views

2 Answers

Best answer
5 votes
5 votes

Compiler dependent. 

Why?

A sequence point defines any point in a computer program's execution at which it is guaranteed that all side effects of previous evaluations will have been performed, and no side effects from subsequent evaluations have yet been performed. They are often mentioned in reference to C and C++, because they are a core concept for determining the validity and, if valid, the possible results of expressions. Adding more sequence points is sometimes necessary to make an expression defined and to ensure a single valid order of evaluation.

The compiler will evaluate printf's arguments in whatever order it happens to feel like at the time. It could be an optimization thing, but there's no guarantee: the order they are evaluated isn't specified by the standard, nor is it implementation defined. There's no way of knowing.

But what is specified by the standard, is that modifying the same variable twice in one operation is undefined behavior; ISO C++03, 5[expr]/4:

Between the previous and next sequence point a scalar object shall have its stored value modified at most once by the evaluation of an expression. Furthermore, the prior value shall be accessed only to determine the value to be stored. The requirements of this paragraph shall be met for each allowable ordering of the subexpressions of a full expression; otherwise the behavior is undefined.

So D is correct.

Ref: https://en.wikipedia.org/wiki/Sequence_point

https://stackoverflow.com/questions/1270370/printfd-d-d-n-a-a-a-output

selected by
0 votes
0 votes
Answer is A

7 6 5

i=5

i++ is post increment so

(i++,i++,i++)=(7,6,5)
Answer:

Related questions

3 votes
3 votes
1 answer
1
admin asked Mar 30, 2020
1,755 views
Output of following program? #include<stdio.h void dynamic(int s,...) { printf("%d",s); } int main() { dynamic(2,4,6,8); dynamic(3,6,9); return 0; }$2\:3$Compiler Error$4...
4 votes
4 votes
1 answer
2
admin asked Mar 30, 2020
2,061 views
Assume that size of an integer is $32$ bit. What is the output of following ANSI C program? #include<stdio.h struct st { int x; static int y; }; int main() { printf(%d",s...
3 votes
3 votes
2 answers
3
admin asked Mar 30, 2020
1,542 views
Output of the following program?#include<stdio.h struct st { int x; struct st next; }; int main() { struct st temp; temp.x=10; temp.next=temp; printf("%d",temp.next,x); r...