Register Now

Login

Lost Password

Enter your email to reset your password.

BY Author

C Variables & constant

Variables

Variables are identifiers.
They are the names given to memory location that are used to store values.
Each memory location has a unique address.
They can store the values of a type they are declared by using suitable data type.

For Example

int i = 5;

Here i is a variable of type int.
Therefore it can store values/constants of integer type only.
Number 5 is an integer constant.
Integer constant (value) 5 is stored at certain memory location whose name is i and of type int.

C Programming Variable & Constant representation in memory

Constants

The value that cannot be altered is known as a constant.

Type of constants

C Programming Types of Constants

Integer constants

Numbers without fraction are called integer constants.

Following are the types of integer constants:

i) Decimal constant (with base 10)

It uses digits – 0,1,2,3,4,5,6,7,8,9.
Few examples of Decimal constant

0, 1, 10, 30, 1002, etc.

ii) Octal constants (with base 8)

It uses digits – 0,1,2,3,4,5,6,7.
Few examples of Octal constant

07, 033, 0321, etc.

iii) Hexadecimal constants (with base 16)

It uses 16 distinct symbols – 0 to 9 & A,B,C,D,E,F (Uppercase/Lowercase).
Few examples of Hexadecimal constant

0X84, 0XA, 0X6DB3, etc.

Real constants

Numbers with fraction are called real constants.
Example

0.1, 5.3, -63.9, 999.9, 9.5e-3, 6.3e2, etc.

Character constants

A character between single quotes is known as a character constant.
Example

‘A’, ‘X’, ‘P’, ‘ ’, ‘$’, etc.

String constant

A constant between double quote is known as a string constant.
Example

“C programming”, “ ”, “A”, etc.

 

Leave a reply