In the previous chapter we have learnt about basic concept of Tokens, Keywords, Identifier, compilation and execution process of c etc. In this chapter we are going to learn about the **Variables and Constants** in C Programming.

## Variables and Constants in C programming:

## Variable:

As the name suggest, Variable is a memory location that can be used to store data whose values can be altered in program based on certain condition.

**Syntax:**

Data_type identifier_name;

**Variable Example:**

1 2 3 4 5 6 7 8 |
#include<stdio.h> int main() { int v1, v2, sum; v1 = 100, v2 = 200; sum = v1 + v2; printf (“Sum of V1 and v2 is = %d \n”, sum); } |

In the above program v1, v2, sum are the variables which holds the value which can be changed.

## Constants:

Constants are the data values which cannot be altered or modified throughout the program whose value is fixed for the entire programs. Constants are of following type:

- Integer constant
- Character constant

- String constant
- Floating constant

**Integer constant:**

There are of three types of integer constant

- Decimal constants-0,1,2,3,4,5,6,7,8,9(base 10).
- Octal constants-0,1,2,3,4,5,6,7 (base 8).
- Hexadecimal constants- 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F(base 16).

**Character constant:**

These are generally written under single quote.

For example: ‘A’,’B’,’>’ etc.

**String constant:**

These constants are written under double quotes.

For example:”[email protected]”

**Floating constants:**

These are constants used to represent floating point values. Floating constants have these type: float, double or long double, exponential

For example:

9.5f –float constant

9.5- double constant

9.5l- long double constant

3.5e0- exponential form double constant