Both C and Java are high-level language.
Both language provides support for variable increment such as the statement: “c++”, “++c”.
However I have discovered some difference between them, where my knowledge is not able to define it currently.
Consider a piece of code in C:
#include <stdio.h>
int main(void) {
int c = 1;
c = c++ + ++c;
printf("this c: %d", c);
return 0;
}
The output will be c = 5;
#include <stdio.h>
int main(void) {
int c = 1;
c = c++ + c++;
printf("this c: %d", c);
return 0;
}
The output will be c = 4;
However in Java,
int c = 1;
c = c++ + ++c;
System.out.println(c);
int d = 1;
d = d++ + d++;
System.out.println(d);
The output will be c = 4 and d = 3
Therefore, this is the difference between inner execution structure for both language and need to be researched in order to fill in the blank here.
To be continued…