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.

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


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.
123,123.45,5


Decimal/Float


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

Character


A character constant includes any single character within the range of ASCII or any character type by keyboard in single quote.
‘a’,’A’,’5’,’+’               

String


A string constant includes one or more than one character within double quote.
“A”,”123”,”Girfa”,”Girfa12@#+”

Variable


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.

Syntax
<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 


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