C language variables, constants and expressions


1. The principles of variable naming 1. It must start with an underscore in an English letter and is a character sequence consisting of letters, numbers and underscores.
2. Cannot have the same name with C language keywords (reserved words).
3. C language is sensitive to the case of variable names.
4. In the long-term use of the C language, some customary rules have been formed: try to use the variable name to express the meaning of the variable.
5. It is best not to use an underscore as the beginning of a variable name.
6. The identifiers of symbolic constants are in uppercase letters, and variable identifiers can be combined with uppercase and lowercase (not all uppercase).

2. Forced type conversion (display conversion)
General form: (type name) expression
Function: convert the expression into the type specified by "type name".
For example:
float x = 6.5;
int y = (int)x;
//Forcibly convert single-precision x to int type and assign it to y, then the value of y is 6, but the type of variable x is still single-precision floating point Type, whose value x is still 6.5

Note: Whether it is automatic type conversion or forced type conversion, it is only a temporary conversion of the variable to participate in calculations and operations. The type and value of the variable itself have not changed.

Guess you like

Origin blog.csdn.net/weixin_43553142/article/details/112394379