What are constants in the C language?
Constants in the C language are values that cannot be changed in a program. They can be classified into different types.
- Integer constants: An integer constant is a whole number that can be represented in decimal, octal, or hexadecimal form, such as 10, 012, 0xA.
- Floating-point constants: Floating-point constants are numbers that can be expressed in decimal or exponential form, such as 3.14 or 2.5e-3.
- Character constants are single characters enclosed in single quotation marks, such as ‘a’ or ‘b’.
- String literals are a sequence of characters enclosed in double quotation marks, such as “Hello, World!”.
- define the following
- The value of PI is defined as 3.1415926.
Constants can be used directly in the program without the need for assignment operations.