0
#include<stdio.h>
void main() {
    int x = 5;
    int y = 10;
    int z = ++x * x++ * --y * y--;
    printf("%d\n", z);
}
Output: 3402

public class Main {
    public static void main(String[] args) {
        int x = 5;
        int y = 10;
        int z = ++x * x++ * --y * y--;
        System.out.println(z);
    }
}
Output: 2916

The Evaluation of theses expressions in C and Java are confusing can someone please help Me, what am i missing? I understand how this works in Java but am confused wrt C.

  • Your C compiler will be confused too - those statements don't mean anything in C, they have undefined behavior. Trying to apply knowledge from Java to C code is not a good idea at all - they have some syntax similarity but that's about it. Don't rely on your Java knowledge when reading C. – Mat Dec 30 '20 at 18:41
  • Thanks for the valuable suggestion. But i wanted to know the evaluation rules of operators for different programming languages be different? Thanks! – Karthik Kashyap Dec 30 '20 at 18:54

0 Answers0