1. Integer constants
Integer constants refer to direct and practical integer constants, also known as integer constants or integers, for example, 1, -9, etc. Integer constants can be long integer, short integer, signed integer and unsigned integer.
a) Octal number
Octal integer must start with , that is, it is prefixed with . Numbers range from to 7. Octal numbers are often unsigned numbers
b) Decimal numbers
Decimal numbers do not need to be prefixed. The decimal number consists of the numbers -9.
c) Hexadecimal number
The constant is prefixed with x, indicating that the constant is expressed in hexadecimal. Numbers contained in hexadecimal are composed of -9 and letters a-f (letters in hexadecimal numbers can be in uppercase form or lowercase form. )
Integer data are stored in the computer in binary form, and their values are expressed in the form of complement. A positive number's complement is the same as its original code form, and a negative number's complement is to take the binary form of the absolute value of the number bitwise and add 1.
2. The real type constant
is called floating-point type, which consists of integer and decimal parts, and is separated by decimal points. There are two ways to express real numbers: scientific counting and exponential.
a) scientific counting method
scientific counting method is to use decimal decimal method to describe real type
b) exponential method
If the real number is very large or very small, using scientific counting method is not conducive to observation. At this time, you can use exponential method to display real variables. Use the letter e or e for exponential display, such as 45e2 for 45, and 45e-2 for .45
When writing a real constant, you can add that symbol f or l to modify it.
F indicates that the constant is a float single precision type, and l indicates that the constant is a long double double precision type.
if you don't add a suffix after it, then by default, the constant is double double precision.
3. Character variables
Character constants can be divided into character constants and string constants
a) Character constants
Character constants can be divided into general character constants and special character constants.
use a single apostrophe to enclose a character, that is, a character constant. The following points should be noted when using character constants:
Character constants can only be enclosed by single apostrophe, and single quotation marks or other brackets are not allowed.
a character constant can only contain one character, not a string.
character constants are case-sensitive.
The single apostrophe represents a delimiter and is not part of the character constant.
A single apostrophe can contain all realistic single characters except' and \ in the C language character set, such as numbers and letters, but numbers cannot participate in numerical operations after they are defined as characters.
special character constants are escape characters. Transferred characters are a special form of representing characters in C language, which means converting characters after backslashes into other meanings.