Constants and Literals

Constants are the fixed values that never change during the execution of a program. Constant values used within a program are also known as Literals. These constant values occupy memory but do not have any reference like variables. Following are the various types of constants:

Integer constants

An integer constant is nothing but a value consisting of digits or numbers. These values never change during the execution of a program. Integer constants can be octal, decimal and hexadecimal.

Example, 111, 1234

Character constants

A character constant contains only a single character enclosed within a single quote (''). We can also represent character constant by providing ASCII value of it.

Example, 'A', '9'

String constants

A string constant contains a sequence of characters enclosed within double quotes ("").

Example, "Hello", "Programming"

Real Constants

Like integer constants that always contains an integer value. 'C' also provides real constants that contain a decimal point or a fraction value. The real constants are also called as floating point constants. The real constant contains a decimal point and a fractional value.

Example, 202.15, 300.00

 

C Language Video

Back - C Language Notes By Vivek Sir email: vivekdubey22@gmail.com (w) 9826424484