Raj is an ardent coder who loves exploring new technology. He is an IT pro with 9 years of exp in C#, Angular, React, Vue.
A programming language helps us process certain kinds of data by providing useful output. The task of data processing is accomplished by executing a series of commands called a program. A program usually contains different types of data, such as integer, float, character etc. A program stores the values being used along with a library function and the user defined function (UDF) to process that stored data. C language is rich in data types and library functions.
C data types can be broadly classified as :
- Primary data types
- Secondary data types
Data Types in C
Primary Data Types in C Language
Primary data types include the following:
Integer Data Type
- Integers are whole numbers with a range of values, the range limits being machine dependent.
- Denoted by the keyword int.
- Generally an integer occupies 2 bytes memory space and its value range is limited to -32768 to +32767 (that is, -215 to +215-1).
- A signed integer uses one bit for storing the sign and 15 bits for the number.
To control the range of numbers and storage space, C has three classes of integer storage:
- short int
- long int
A short int requires half the amount of storage than normal integer. The long integers are used to declare a longer range of values and it occupies 4 bytes of storage space.
All three data types have signed and unsigned forms.
- Unlike signed integers, unsigned integers are always positive and use all the bits for the magnitude of the number. Therefore the range of an unsigned integer will be from 0 to 65535.
Syntax: int <variable name>; like
short int num2;
long int num3;
Example: 5, 6, 100, 2500.
Integer Data Type Memory Allocation
Primary Data Types in C: Float
- The float data type is used to store fractional numbers (real numbers) within 6 digits of precision.
- Floating point numbers are denoted by the keyword float.
- When the accuracy of the floating point number is insufficient, we can use the specifier "double" to define the number. “Double” is the same as “float” but has double the precision and takes up twice as much memory space (8 bytes) as float.
- For even more precision we can use “long double” which occupies 10 bytes of memory space.
Syntax: float <variable name>;
long double num3;
Example: 9.125, 3.1254.
Floating Point Data Type Memory Allocation
Primary Data Types in C: Character
- The character type variable can hold a single character.
- "Char," like "int," may be singed or unsigned. Both signed and unsigned occupy 1 byte each but have different ranges. Unsigned characters have values between 0 and 255; signed characters have values from –128 to 127.
- Denoted by char.
Syntax: char <variable name>;
char ch = ‘a’;
Example: a, b, g, S, j.
Primary Data Types in C: Void
- The “void” data type returns no data; it is not a variable like the other types. It may be used with functions that need to be run without returning any values.
- For example, we can declare “main()” as a void type because it does not return any value.
User-Defined Type Declaration in C Language
C language supports a feature where the user can define the identifier that characterizes an existing data type. This user-defined data type identifier can later be used to declare variables. In short, its purpose is to redefine the name of an existing data type.
Syntax: typedef <type> <identifier>;
Example: typedef int number;
Now we can use number in lieu of int to declare integer variable. For example: if we enter int x1 or number x1 both statements declare an integer variable. We have just changed the default keyword int to declare integer variable as number.
Size and Range of Data Types in C Language
Secondary Data Types in C Language
- Arrays: collections of data of a similar type.
- Pointers: a way to refer to information by referring to the address where the information is kept.
- Structures: a way of associating data of different types.
- Unions: a way of allowing the same data to be read as data of different types.
- 2d Array in C Programming Language
We know how to work with an array (1d array) with one dimension. In C language it is possible to have more than one dimension in an array. This tutorial explains how we can use two dimensional arrays (2D array or matrix array) to store values with ex
- String and String Pointer in C Programming Language
String program in C language could be little tricky and this tutorial aims to simplify it. This tutorial explains how to use character array & pointer to store and retrieve string along with different ways to read string input from user.
- Loop in C Programming Language
Loop is one of the important parts of C language and study of C language is incomplete without this. So let’s head towards completion of our knowledge about C language. As a dedicated C language leaner, right now you should have two questions. What i
- Functions in C Programming Language
A function in C language is a block of code that performs a specific task. It has a name and it is reusable i.e. it can be executed from as many different parts in a C Program as required. It also optionally returns a value to the calling program So
- What Is an Array in C Programming Language
what is an array in c programming, this tutorial explains it with example and line by line explanation.
© 2009 RAJKISHOR SAHU
Obzy on June 29, 2017:
What is the size and range of viod
diksha koushal on January 20, 2015:
nicomp really from Ohio, USA on January 13, 2015:
The char type should not be confused with a character. It's simply a 1-byte integer, usually. It can 'hold' any integer value within the given range. A one-byte signed char, for example, has the range -128 through +127.
Aadil Syed on September 10, 2014:
awesom programing c but its vry complicated......
nikita on July 25, 2013:
thanks for information
ss on July 23, 2013:
mushkin on July 07, 2013:
thanks its very easy to understand,not any confuse
rajendra on June 22, 2013:
please give me all notes of c langauge with programme........
manjunath on June 22, 2013:
its very useful to students thank u
udhayan on May 05, 2013:
than q very much....this helped me a lot:)))
sania angle on February 16, 2013:
RAJKISHOR SAHU (author) from Bangalore, Karnataka, INDIA on January 24, 2013:
Well said @sonuxrt, I published this article on this site on 04/07/2009 and that site came into existence on Sat, 26 Nov 11 11:14:14 +0400 see link http://eazynotes.com.whoisbucket.com I didn't know know that I am so good in copying content :P.
sonuxrt on January 22, 2013:
Don't copy from another website
Programminghub from India on January 19, 2013:
Really a nice post Dear...:)
I created a facebook, from where you can download lots of free ebooks and tutorials....(in a single click only..)
C, C++ and JAVA programming tutorials + Much More..
Thank You Raj Kishor..
ALI on December 01, 2012:
Pinku Hazra on September 06, 2012:
By this answer am very helpful,..thanks keep on.
ramesh on July 12, 2012:
ian05 on July 07, 2012:
very helpful... keep it up, do some more... great job.
jhezrylle on June 20, 2012:
anu po ung mga Variables ng c language?/
jawadmalik on June 20, 2012:
its working ... :)
RAJKISHOR SAHU (author) from Bangalore, Karnataka, INDIA on April 30, 2012:
thanks for visiting my friend...
waqas Amanat on April 29, 2012:
its really a very helpful for students & others. it helped me a lot in my exams..thankx a lot
Masabo Christophe on April 19, 2012:
thank you for teaching, then you add more programms
simran on April 03, 2012:
thanks for uploading this information
really its very help me
abhinav vats on March 30, 2012:
it is very helpful so plz keep it up
magoo on March 27, 2012:
that was short and precise, thank you!
Hasnain on March 26, 2012:
If any one have any good material regarding c & c++,plz send me at firstname.lastname@example.org
Ramisha Rukhsar on March 15, 2012:
plz tell me about the problems of floating point used in c programming language.plz tell me ans as soon as possible
monisha on March 12, 2012:
what is abstract datatype?
Arun Mavi on March 12, 2012:
It is hard for UP board students only otherwise it is easy
priyanka on March 03, 2012:
Thanks, it helps me a lot
Java Programs from India on February 26, 2012:
Excellent hub on Data types in C.... I am also a software developer and have started writing for hubpages under category of Java. I have published my first hubs as :
have a look .... Thanks for the wonderful information...
ankur on February 25, 2012:
can u tell me where the data type store in comp.memory
jaswant kumar on February 17, 2012:
i think four batter c program tools this web site
anchal on February 17, 2012:
kuch samajh nah araha
santhosh kumar on February 15, 2012:
it's intresting..... but i dnt know c program.....
pls help me....
raj on February 06, 2012:
why we need range for datatype like int as -32708 to 32627?
mekhzam on February 02, 2012:
this is very nice
Ajay bidhauliya on February 02, 2012:
need to few is described
Ajay PAtil on February 01, 2012:
if knw the correct ans den only post otherwise don't post..............don't misguide to people.......plz
who told u dat structure is NOT user defined data type,,,,,,,,,,,,,,,,,,,,buddy
its user defined data type ..pgmer only define types of variables which u Want..................so plzzzzzzzzzzz u knw correcr n accurate ans den post otherwise don't post
kalpana on January 28, 2012:
so confuse and so boring
ravi ranjan on January 27, 2012:
fahad akhtar from pakistan on January 24, 2012:
plzzzz give me about the idea of modulus in algorithm
sree on January 24, 2012:
i dont know c.how to do the programs,so plz give me a suggestion to over come the problem
Md Ali Umar on January 20, 2012:
for double %lf & for long double %Lf, for short signed int %d, short unsigned int %u.
INSI on January 19, 2012:
WAT IS USE OF * IN SCANF STATEMAENT?
dude on January 17, 2012:
how can i print these data types i mean like %d for integer... what for double, long double and short int etc
supriya,s.p.jain college on January 15, 2012:
thank's for deeply information
email@example.com on January 11, 2012:
thankyou very much...............this provides us many hints for further study
Nibedita Swain on January 04, 2012:
What variable? explane pointer variable
md wakash ahmad on January 04, 2012:
why uses # in c program
please reply this topic on that site
kanchan Pande on December 29, 2011:
Can any one tell me,that there are how many data types included in C and C#.
Sanket Sathe on December 26, 2011:
sanjeev kumar on December 22, 2011:
i am define int a=015 and print the value is 13 why plz rply me urgently
kamaluddin ahmed on December 20, 2011:
i want to make indian national flag but how ,i have no idea ,please give me some tips
firstname.lastname@example.org on December 19, 2011:
what's the mean by recursion?
aruna devi on December 18, 2011:
what are data types in c?
krish on December 16, 2011:
very fine historical and briefly knowledge of c. good one
codeguru on December 15, 2011:
this article is so so not good
arvnagendrakumar5 on December 01, 2011:
i love c programs
bk on November 30, 2011:
Too nice sis it is very koalaveru da
adil khan on November 30, 2011:
no compiler not depend on variable..........
Raj on November 29, 2011:
am a student of cse but from bio background so plz help me my email id email@example.com
mobigujjar on November 29, 2011:
I m a stdnt of BS(IT)
plz u help me in this field
plz snd email address to me
Vamshi on November 28, 2011:
Nice site bro..
It is very use full...
yasir lovee on November 24, 2011:
Jst a question that U have not used in data types that is ''Format'' of these data types.Plz justify if so........
prince suwalka on November 23, 2011:
c lang is very mindblowing lang
cheryl on November 23, 2011:
what is the importance of the sizes of the data types in c language?
all bca on November 20, 2011:
c language is so so so so so so easier dude
Sunti Lhatdavong on November 20, 2011:
I like C language
chitti on November 18, 2011:
i gave a seminar using this
chitti on November 18, 2011:
thnk u bro 4 such a good expl
chitti on November 18, 2011:
chitti on November 18, 2011:
nikhil so.... on November 17, 2011:
thank u very much ...:)
jhin_jhin on November 16, 2011:
i liKe it.
dinesh on November 16, 2011:
thank u very much i answered my viva question in my practical session by using this site
faizkiki family on November 15, 2011:
fasial on November 15, 2011:
its support very well for my exam
mohd kashif on November 14, 2011:
ravi on November 13, 2011:
@ sai ram
which branch r u ??
sai ram on November 13, 2011:
i m from b v raju college,studying 1st year,narsapur,medak.
.....please teach me c bro....
sai ram on November 13, 2011:
i know c but i don't knw.... c language wt to do....bro... i beg u teachh c plz bro i touch u r feet..... my num is 9000932558
chinni on November 13, 2011:
its very nice & easy to understand if da logics are clear
m kashif on November 13, 2011:
simple but easy to understand. so execelent
Ravi on November 13, 2011:
The C programming language is a standardized programming language developed in the early 1970s by Ken Thompson and Dennis Ritchie foruse on the UNIX operating system. It has since spread to many other operating systems, and is one of the most widely used programming languages. C is prized for its efficiency, and is the most popular programming language for writing system software, though it is also used for writing applications.
srinu on November 13, 2011:
if we have an intrest, then can we learn this subject very easily,,,,,
RAJKISHOR SAHU (author) from Bangalore, Karnataka, INDIA on November 12, 2011:
@Parvez size of any data type is compiler dependent.
ruji on November 12, 2011:
what is c plz tell me ....
Parvez on November 12, 2011:
Why dos integer datatype in c take 4 bytes in visual studio ?
plsss reply back!!!
teja on November 08, 2011:
what is the use of %u in c language
Syed Zaheer on November 05, 2011:
This web side is awesome, i got good notes for c n have also learn answers soo tnks
vallabhi on October 31, 2011:
love U C................Learning U is just playing with a friend
Karan on October 27, 2011:
suyash47 on October 23, 2011:
Array in C programming
An array in C language is a collection of similar data-type, means an array can hold value of a particular data type for which it has been declared. Arrays can be created from any of the C data-types int,...
sajan on October 23, 2011:
i luve studyin c programming. studying
sajan on October 23, 2011:
i love c programming its very useful.
rahul on October 19, 2011:
i want to know about c, its very intresting, but also hard for me.
tamanna on October 19, 2011:
too difficult and bkkwwaaaaaaaaasss
twinkle on October 19, 2011:
i hate c i don't like 'c' language okkkkkkkkkkk