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.

  1. Integer constants: An integer constant is a whole number that can be represented in decimal, octal, or hexadecimal form, such as 10, 012, 0xA.
  2. 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.
  3. Character constants are single characters enclosed in single quotation marks, such as ‘a’ or ‘b’.
  4. String literals are a sequence of characters enclosed in double quotation marks, such as “Hello, World!”.
  5. define the following
  6. The value of PI is defined as 3.1415926.

Constants can be used directly in the program without the need for assignment operations.

Leave a Reply 0

Your email address will not be published. Required fields are marked *


广告
Closing in 10 seconds
bannerAds