C Programming Constants: Rules & Examples

  1. Integer constants: Integer constants can be numbers in decimal, octal, hexadecimal, or binary format, such as 10, 012, 0x1A, 0b1010, etc.
  2. Floating point constants are numbers that include a decimal point, such as 3.14 and -0.23.
  3. Character constants: Character constants are enclosed in single quotes, such as ‘A’, ‘b’, ‘1’, etc.
  4. String constants: Strings are enclosed in double quotation marks, for example “Hello, World”.
  5. Symbolic constants: Symbolic constants are defined using the #define directive, for example #define PI 3.14159.
  6. Enumerate constants: Constants are defined using the enum keyword, for example enum color {RED, GREEN, BLUE}.
  7. Macro definition constants: Constants defined using the #define directive are also known as macro definition constants, for example #define MAX 100.
  8. Other constants: There are also some special constants, such as NULL representing a null pointer constant, true and false representing true and false.
bannerAds