541 views

1 Answer

Best answer
4 votes
4 votes

How this is executed?

Only the person who wrote the particular version of the compiler can even predic this. Because in the following statement two modifications to the same variable happens without a sequence point in between (usage of ',' in argument list is not a sequence point though comma operator is), and hence the behavious is not defined by C standard and falls under Undefined Behaviour category.

printf("%d %d",p++,++p);

Now printf function is executed left-right or right-left?

I suppose you meant the order in which arguments to printf are processed. This is also not defined by C standards and compiler is free to choose as it like or the programmer is not supposed to make any assumption about this.

Why these questions are never asked in exams like GATE/TIFR?

Because they have better things to do.

Why there are less innovations from Indian Engineers?

Who told, only we can innovate these questions. While people abroad innovate things like Facebook and all we spend our time innovating and solving these kind of questions. Just google or search in Facebook C groups- at least half of the posts will be such questions being asked by Indian students.

Read More: https://gateoverflow.in/62411/what-is-the-output

selected by

Related questions

0 votes
0 votes
1 answer
1
Ankush Tiwari asked Aug 20, 2016
469 views
#include<stdio.h int main() { char *p1="xyz"; char *p2="xyz"; if(p1==p2) printf("equal"); else printf("unequal"); }Output is equal how??? please explain
1 votes
1 votes
1 answer
2
komal07 asked Aug 18, 2016
1,061 views
#include<stdio.h #define CUBE(x) (x*x*x) int main() { int a, b=3; a = CUBE(b++); printf("%d, %d ", a, b); return 0; }Why this give 27,6 as output?
1 votes
1 votes
2 answers
3
Sanjay Sharma asked Nov 17, 2016
858 views