Tutorial 2: Variables and Data Types

Variable is a memory location that can store a value. The stored value can be retrieved or modified when necessary. Initialization of a variable means a value is given to the variable during its declaration. When a variable is declared, its name and data type are specified.

A variable name can contain letters, digit and underscore (_). It cannot begins with a digit. C is case sensitive, therefore v and V are considered two different variable names. Its data type is given to specify what type of data can be stored in the variable.

There are four basic data types in C programming language: int, float, double and char. Each data type has its own size. The size of a variable is the memory space allocated in the memory required to store its value. The following example demonstrates on how to declare a variable for each data type.

The statements declare four variables of types int, float, double and char with the name of num1, num2, num3 and letter. Now that we have declared the variables, lets look at how to initialize them.

We use '=' (assignment operator) to initialize the variables such as the value of 5 into variable num1. We could also perform the declaration and initialization on a single statement. This is demonstrated in the following program.


GMJ said...


Techbee web Solution said...

am a beginner to C Programming Language, Good Post
C Tutorial For Beginners

Hardik H Hadvani said...

Hey admin,
of course this blog is doing a very good job of serving useful information. I'm proud to be a part of its Readers community.
for more programing visit my web

Kishan Bhalodia said...

hi dude i am visit you site and its relay very very nice.
I have one site but i am in some trouble not more visitor in my site, so please tell me what am i do for more visitor.

Hardik H Hadvani said...

Hey dude Thank you for this awesome article on C.
please post an article on Simple Calculator in C

Axay Makadiya said...

Nice article man. I hope I will get a Good Results 2014 out of this piost

Mir Mahfuz said...

i feel proud to be a meber of this site.

akmal niazi khan said...

Programming is very interesting and creative thing if you do it with love. Your blog code helps a lot to beginners to learn programming from basic to advance level. I really love this blog because I learn a lot from here and this process is still continuing.
Love from Pro Programmer

Post a Comment