Common mistakes in basic syntax of C language

1. Constant definition: #define FINAL 1000
is easily recorded as: #define FINAL = 1000;
FINAL is an lvalue that cannot be modified.
2. Division operation: If the two numbers divided are both integers, the result will also be an integer, and the decimal part will be ignored, such as: 8/3=2;
if one of the two numbers is a decimal, the result will be a decimal.
In the process of writing a program, it is easy to divide two integers to perform the next operation on the obtained decimal result, resulting in errors in the running results and difficulty in checking the error code.
3. Remainder is only suitable for using two integers.
The sign of the operation depends on the sign of the modulus.
For example: (-10)%3 = -1;
10% (-3) = 1;

Guess you like

Origin blog.csdn.net/qq_46012097/article/details/124508871