Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - Legal rules of c language constants
Legal rules of c language constants
What constants are legal in C language?

Constants in C language: direct constants and symbolic constants. Direct constant refers to a form directly expressed by concrete data, which can be divided into integer constant, real constant, character constant and string constant. Symbolic constants are constants defined by C language identifiers.

Character constants can be ordinary characters (such as x), escape sequences (such as \t) or ordinary characters (such as \u02C0).

A: Commas are not allowed in integers; B: Scientific notation means that 5 times the power of 10, because the exponential part of scientific notation can only be an integer.

Because it is hexadecimal, it must start with 0x. Item c starts with 0, which means octal, but the x at the end is illegal. Item D starts with 0x, which means 16, so f means 15, which is legal. The l at the end stands for long, which means that this constant is a long integer.

C language legal constant

A, legal, decimal constant: numerical sequence, optional, numerical sequence. B, 0 1aa is illegal, which does not mean that the character a. C. e5 is illegal. C language grammar stipulates that there must be a number before the letter e or e, and the index after e or e must be an integer.

Symbolic constants: constants are represented by identifiers. In C language, a constant can be represented by an identifier, which is called a symbolic constant.

Character constants can be ordinary characters (such as x), escape sequences (such as \t) or ordinary characters (such as \u02C0).

Constants in C language are fixed values and cannot be modified by programs. Constants can be of any data type, as shown in the following example: data type. C language also supports another constant with a predefined data type, namely string. All string constants are enclosed in double apostrophes, such as Thisisatest.

B, 08 1, which is illegal. 10 decimal number cannot be preceded by 0. If the first digit is 0, it means that this number is octal. But in octal numbers, there can't be 8 (8 will carry and become 10), so this is wrong. If it is 16, 0x8 1, this is correct.

Because it is hexadecimal, it must start with 0x. Item c starts with 0, which means octal, but the x at the end is illegal. Item D starts with 0x, which means 16, so f means 15, which is legal. The l at the end stands for long, which means that this constant is a long integer.

Legal rules of c language constants

1, legal analysis: constants in C language: direct constants and symbolic constants. Direct constant refers to a form directly expressed by concrete data, which can be divided into integer constant, real constant, character constant and string constant. Symbolic constants are constants defined by C language identifiers.

2. Legal variable name: it can only be composed of numbers, characters and underscores. It cannot start with a number. In addition to meeting the above conditions, it cannot be the same as the defined function name and system name (for example, intdouble cannot be defined).

3. Constants in C language are fixed values and cannot be modified by programs. Constants can be of any data type, as shown in the following example: data type. C language also supports another constant with a predefined data type, namely string. All string constants are enclosed in double apostrophes, such as Thisisatest.

4. Character constants can be ordinary characters (such as x), escape sequences (such as \t) or ordinary characters (such as \u02C0).

Is-100 a legal constant in C language?

In 1 and C languages, constants defined according to established rules are legal numerical constants, which are divided into the following three types: decimal integer is the usual integer writing. For example: 1 12 1 etc. Octal integer Octal integer is written by adding a number 0 before the usual octal integer.

2./* legal */215u/* legal */0xfeel/* legal */078/* Illegal: 8 is not an octal number */032UU/* Illegal: the suffix cannot be repeated */Floating-point constant consists of an integer part, a decimal point, a decimal part and an exponent part.

3. Concept of constant: A constant refers to an amount whose value cannot be changed during the running of a program. Constants in C language: direct constants and symbolic constants.

4. Constants in C language are fixed values and cannot be modified by programs. Constants can be of any data type, as shown in the following example: data type. C language also supports another constant with a predefined data type, namely string. All string constants are enclosed in double apostrophes, such as Thisisatest.

5.0Xa235e0, -0xf.5e-3. 177 is legal. Real constant: there must be a decimal point. For example, it is wrong to define doublea= 1, and it must be written as doublea=0. In addition, it must be written as a= 1, and there is a comma in 0, which is even more wrong.

6.a, legal, decimal constant: numerical sequence, optional, numerical sequence. B, 0 1aa is illegal, which does not mean that the character a. C. e5 is illegal. C language grammar stipulates that there must be a number before the letter e or e, and the index after e or e must be an integer.

What is a legal C constant and what is an illegal C constant? Please give a detailed definition and explanation.

1, concept of constant: A constant refers to an amount whose value cannot be changed during the running of a program. Constants in C language: direct constants and symbolic constants.

2. Constants in C language are fixed values and cannot be modified by programs. Constants can be of any data type, as shown in the following example: data type. C language also supports another constant with a predefined data type, namely string. All string constants are enclosed in double apostrophes, such as Thisisatest.

3. No, the concept constant of constant refers to the quantity whose value cannot be changed during the running of the program. Constants, direct constants and symbolic constants in C language. The legal constant requirement of C language means that its value cannot be changed during the running of constant program.