• retagged by
1,924 views
0 0 votes

What is the output of this program?


int main(void)

{
int a = 10, b = 20, c = 30;
printf(" %d..%d..%d ", a+b+c, (b = b*2), (c = c*2));
return 0;
}
(A) 60..40..60
(B) 110..40..60
(C) 110..20..30
(D) 60..20..30

does sequence point comes into picture here?

1 Answer

0 0 votes
For printf() the sequence point is defined from right to left. Evaluation starts from right to left . But there is lot of debate going on regarding this at all the platforms. I have seen this type of questions even in C++,where it was cout statement. So , Just go with right to left evaluation .

I have followed this.

So , the answer will be option B) when right to left is considered the order of evaluation .
Position:
Show:

Related questions

3 3 votes
2 answers 2 answers
836
836 views
kirmada asked Jun 20, 2024
836 views
#include <stdio.h int main() { // Write C code here int i=10,*p, q, *r; p=&i; *p=15; q=&p; q=20; r=&q; *r=*p+1; printf("%d",i); return 0; }answer the output as integer ...