+ 1
How this output came?
#include<stdio.h> int main() { int a = 10; printf("%d %d %d",a,++a,a++); return 0; } the output is 12 12 10 But how? Please Explain.
3 odpowiedzi
+ 1
My bad. After reading this stackoverflow question, the function parameters aren't evaluated in a defined order.
https://stackoverflow.com/questions/376278/parameter-evaluation-order-before-a-function-calling-in-c
Meaning this code might give different results on different compilers.
+ 1
It evaluates the arguments randomly. In this case, it executes a++ first which returns 10, then ++a which returns 12 and a which also returns 12.
+ 1
in all the printf statements in c does it do calculation from right to left?