/******************************************************************************
Welcome to code of Lập trình - Điện tử
Series: C
Author: Nghĩa Taarabt
*******************************************************************************/
#include <stdio.h>
int main() {
int x = 10, y;
// Tiền tố
y = ++x; // x tăng lên 11, y = 11
printf("Prefix: x = %d, y = %d\n", x, y); // x = 11, y = 11
// Hậu tố
x = 10; // Reset x
y = x++; // y = 10, x tăng lên 11
printf("Postfix: x = %d, y = %d\n", x, y); // x = 11, y = 10
// Sử dụng trong biểu thức
x = 5;
printf("Prefix in expression: %d\n", ++x * 2); // (6) * 2 = 12
x = 5;
printf("Postfix in expression: %d\n", x++ * 2); // (5) * 2 = 10, x = 6 sau đó
return 0;
}