Sunday, 9 October 2016

Introduction of Variable in C Language

Variable in any programming language when we start programming then first thing which we start with is variable. This chapter will give full knowledge of variable’s operation .So let’s start learning process with constant.


A constant is a value that newer get change. Like value of g (gravitational force) is 9.8, value of PI is 3.14 or your date of birth. Examples of different type of constant are follows


Integer is numbers that exclude decimal part. For Example if I ask to you that how many siblings you have. Your reply will always be in integer without decimal part.


Decimal or float are number which include integer with decimal part. Example of decimal number is your age, exam marks, price etc.


A character constant includes any single character within the range of ASCII or any character type by keyboard in single quote.


A string constant includes one or more than one character within double quote.


A variable is accumulator which store data that can be change. Every variable in C language has a specific data type so variable store only those data types which defined at the time declaration.

<data_type>  Variable_name ;

Int a;
Int b=0;

First line declares variable named a occupies two byte. Second line declares variable named b and assign it by 0.

Data type information table for 16 Bit 

Storage size
Value range
Input / Output Symbol
1 byte
-128 to 127 or 0 to 255
unsigned char
1 byte
0 to 255
signed char
1 byte
-128 to 127
2 or 4 bytes
-32,768 to 32,767 or -2,147,483,648 to 2,147,483,647
unsigned int
2 or 4 bytes
0 to 65,535 or 0 to 4,294,967,295
2 bytes
-32,768 to 32,767
unsigned short
2 bytes
0 to 65,535
4 bytes
-2,147,483,648 to 2,147,483,647
unsigned long
4 bytes
0 to 4,294,967,295



No comments:

Post a Comment