C Programming Tutorial
Computer Tutorial

C Constants and Types of Constants

C Constants and Types of Constants

Constants refers to fixed values or a quantity that does not changed. This quantity can be stored at a locations in the memory of the computer. Constants can be of any of the basic data types. Constants are also called literals.

Type of Constants

C constants can be divided into two major categories :
1. Primary Constants
2. Secondary Constants

Types of C Constants

Types of C Constants

Primary Constants

Primary Constants are Integer Constant, Real Constant and Character Constant.

• Integer Constant

An integer constant must have at least one digit and must not have a decimal point. It can be either positive or negative If no sign precedes an integer constant it is assumed to be positive. The allowable range for integer constants is -32768 to 32767.
Ex- +325.34, 426.0

• Real Constants

Real constants are often called Floating Point constants. The real constants could be written in Fractional form and Exponential form.
A real constant must have at least one digit and must have a decimal point.
Ex- +3.2e-5, -0.2e+3

• Character Constants

A character constant is a single alphabet, a single digit or a single special symbol enclosed within single inverted commas. Both the inverted commas should point to the left. For example, ’A’ is a valid character constant whereas ‘A’ is not. The maximum length of a character constant can be 1 character.
Ex- 'A', '5'