Course Content
History of C Language
0/2
Basic Structure of C Program
0/1
Types of Errors
0/1
Language Fundamentals
0/1
Data Types and Modifiers
0/1
Programming with C Language
About Lesson

Data Element is a type of program element that can enable us to store data in memory.  

In this lesson we are discussing about two such data elements that are variable and constant.

 

Variable is a memory location referring with an identifier whose value changes from time to time during program execution.

Declaration of Variables: Declaration associates a group of identifiers with a specific data type.  We can understand declaration as an introduction of an identifier with its characteristics.

Example of Variable Declaration statements:

int a;

float r1,r2;

 

CONSTANT:

A constant is a memory location referred by an identifier whose value cannot be changed throughout the execution of a program.

Declaration of constant can be done with the following syntax:

const =’value’;

Again, the values that can be stored inside the memory location referring by a variable or constant also known as Constants.

Based on the four data types we have four types of constant values:

  1. Integer Constants Eg: 32727, 45, 8
  2. Floating Point Constants Eg: 2.58, 56.0
  3. Character Constants Eg: ‘A’, ‘c’, ‘u’
  4. String Constants Eg: “Rama”, “blue sea”, “ABC123”

 

 

Rules to form Integer and Floating Point Constants

  • No comma or blank space is allowed in a constant.
  • It can be preceded by – (minus) sign if desired.
  • The value should lie within a minimum and maximum permissible range decided by the word size of the computer.

Symbolic Constant is a name associated with a sequence of characters or any basic type of constant.  Symbolic constant is replaced with the constant at the time of compilation.

Symbolic Constants can be defined with the following preprocessor statement:

#define

Eg:

#define print printf

#define MAX 100

#define TRUE 1

#define FALSE 0

#define SIZE 10

You cannot copy content of this page