Constants

In this lesson, you will get to know about constants and their different types in C.

Definition

Constants are values that do not change after they have been defined.

Numeric Constants

An example of an int constant is the number 1234. An example of a floating-point constant (by default typed as a double) is 123.4 and 1e-2. We can write numbers in octal or hexadecimal instead of decimal: octal by using a leading zero (0) and hexadecimal by using a leading zero-x (0x). Decimal 31 can be written as 037 in octal and 0x1f or 0X1F in hexadecimal. Here are some examples of defining numeric constants:

Create a free account to access the full course.

By signing up, you agree to Educative's Terms of Service and Privacy Policy