retagged by
735 views
0 votes
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?

retagged by

1 Answer

0 votes
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 .

Related questions

0 votes
0 votes
1 answer
1
Psnjit asked Jan 12, 2019
1,136 views
main(){unsigned int i= 255;char *p= &i;int j= *p;printf("%d\n", j);unsigned int k= *p;printf("%d", k);} Both the outputs are -1. I have even tried with - int i = 255(3rd ...
3 votes
3 votes
2 answers
2
Shamim Ahmed asked Dec 11, 2018
546 views
char *a = “MADEEASY”;char *b = “GATECSIT2019”;char *r = a;char *s = b;printf(“%d”, (int) strlen (b+3[r] – 1[s]));return 0; Whats the output? Answer given 8
0 votes
0 votes
1 answer
3
Mr khan 3 asked Nov 3, 2018
977 views
#include<stdio.h void fun(int *p,int *q) { p=q; *p=q; } int i=0,j=1; int main() { fun(&i,&j); printf("%d%d",i,j); }What will be the output of i and j in 16-bit C Compiler...