The following program in c outputs 37, as an answer and I am not able to come out with its logic.In other language the answer like java or javascript the output is 36. Can someone please explain the logic for the same in the mentioned languages.
C
#include <stdio.h>
int main(){
int a = 10; //assignment of variable
printf("%d",(++a + ++a + ++a)); // increment the variable
getchar();
return 0;
}
Java
public class postpreincrement {
public static void main(String[] args) {
// TODO Auto-generated method stub
int a = 10;// variable a assigned value
System.out.println(++a + ++a + ++a);// evaluation of expression
}
}
JavaScript
var a = 10; // variable a assigned value
console.log(++a + ++a + ++a); // evaluation of expression