[Learning notes] [C Language] constant, learning notes constant
1. What is a constant?
Constant, indicating some fixed data
2. Constant Classification
1> integer constant (int)
Contains all integers, such as 6, 27, 109, 256,-10, 0, and-289.
2> float type constant (float \ double)
* Float constants are classified into double and float data types.
Double: double float type, which is actually decimal. For example, 5.43,-2.3, and 0.0 (note that 0.0 is a decimal number)
Float: Single-precision floating point type, which is also a decimal point, which is less accurate than double, that is, it can represent less decimal places. To distinguish it from double, float data ends with f, such as 5.43f,-2.3f, and 0.0f. Note that the 10f format is absolutely not supported. the compiler will directly report an error and only allow f to be added to decimal places.
3> character constant (char)
Convert a number (0 ~ 9), English letters (~ Z, ~ Z) or other symbols (+ ,-,! ,? And so on. For example, '6', 'A', 'F', '+', and '$.
Note: single quotes can only contain 1 character and cannot contain Chinese characters. The following statements are incorrect: 'abc', '123', and 'mal'
4> string constants
Enclose one or more characters in double quotation marks ("") to form a String constant.
For example, "6", "male", "Wow haha", "abcd", and "my_car4", in fact, printf ("Hello World"); "Hello World" in the statement is a String constant.