There are many kinds of integer constants, such as int, char, enum enumeration constants, and bool type is also one of the integer constants in C++.
General switch statements use this format switch (expression) {case constant expression 1: statement1; ... case constant expression 2: statement 2; Default: statement; }
The switch is an integer expression. Case is an integer constant expression. Therefore, floating-point numbers cannot be used. Personally, it is difficult to grasp the precision of floating-point numbers, and multiple matches may occur within a certain error range. Moreover, floating-point numbers have high requirements on hardware dependence, and code portability may be low.
Character variables in C language cannot be stored in integer constants.
Yes, it can't be stored.
Because the key to integer constants is constants, that is, they are initialized when they are defined, and can no longer be assigned with variables.
The difference between integer constants and character constants
Character constant: a character enclosed in single quotation marks, such as "a", "0", "0" and "n". In a computer, a character occupies a byte, and its value is the ASCII value of the character, for example,' a'=97 '0'=48.
Integer constant: it is our common integer, such as 12, 123, 1000 ... which is also expressed in hexadecimal: 0x 10( 16) 0xff(255) is also expressed in octal. ) 0 15( 13) and so on.
C language about character constants
In a computer, an ASCII character is an 8-byte number, but when it is displayed, it is displayed with a character that people know. For example, the' a' stored in the computer is the number 65.
What is the integer constant in C language?
Integer constant, that is, integer constant, is a decimal number with 10, such as 123, -345.
Octal number starting from 0
There are also 16 hexadecimal numbers starting with 0x. ..
0.5 12F is () a. integer constant B. character constant C. floating point constant D. illegal constant.
Floating point type
What is the integer constant in C language?
const int count = 60
Count is an integer constant. When declaring, the declaration is an integer, and the value is unique and will not change again, so it is an integer constant.
How many kinds of C language constants are there? For example: integer constants, floating-point constants, character constants, enumeration constants, what other constants?
Integer, for example:-123, 0xff (hexadecimal), 022 (octal)
Real types, such as: 3. 14, 3. 14f (single essence), 3. 14lf (double essence), 1.2e04 (science).
Character constant, "a"
String constant, "abc 123"
Escape character constant' \0' "\n "
The macro definition identifier constant # define2.7 1 E in the program will be replaced by 2.7 1 at compile time.
Logical constant TRUE (in fact, it is also a macro-defined constant) ...
What are the characteristics of long integer constants in C language?
Long integer: signed integer; Meet sizeof (long) gt; =sizeof(int), generally the sizeof(long) of a 32-bit platform is 4; In addition, due to the sizeof (short)
2. Constant: cannot be modified.
In C language, constants are numeric values. Text suffixes are l or l, which means long, for example, 1234L, 0l. If there is no suffix, it defaults to int literal instead of long literal, that is, it is not a long integer constant.