Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - What are the constant expressions in C language? Give a few examples, thank you! ! !
What are the constant expressions in C language? Give a few examples, thank you! ! !
Constants, Constant Expressions and Variables in C Language

An amount whose value cannot be changed during the running of a program is called a constant.

Integer constants: 1, 0,-1.

Real constant: 8.2, -3.55

Character constants: "a", "c"

Constants can usually be judged from their literal forms. This constant is literal or direct.

Integer constants can be divided into: int, short int, long int, unsigned int, unsigned short, unsigned long.

Floating-point constants can be divided into: float, double and long double.

Character constant:

String constant:

Variables: Variables represent storage units with specific properties in memory, which are used to store data, that is, the values of variables.

Just like cout

Can a constant expression be considered a constant? Generally speaking, yes, as long as there are no variables.

Constant expressions, as the name implies, are represented by constants, such as

double a = 3d+2. 1+sizeof(double);

Integer expressions are expressions represented by integer data.

a[n];

Dimension size n must be an integer, and the system will not automatically convert low-precision numbers into high-precision degrees. All a[3.4] are incorrect, it must be a[(int)3.4].

-

An expression consists of a series of numbers and symbols. For example, 1+2 is an expression, and 12*8- 1*99 is also an expression. C++

Besides the ordinary arithmetic operation+-*/,there are other "symbols".

A constant expression is a formula with only constants in the expression. For example, 1+2 is a constant expression. If a is defined as a constant 1, then a+2 is also a constant expression.

If the variable A is defined, then a+2 is not a constant expression.