Flag This Hub

C Programming Lesson - Data Types in C Language

By


A programming language is proposed to help programmer to process certain kinds of data and to provide useful output. The task of data processing is accomplished by executing series of commands called program.A program usually contains different types of data types (integer, float, character etc.) to store the values being used in the program along with some library function and user defined function (UDF) to process that stored data. C language is rich of data types and library function. A C programmer has to employ proper data type as per his/her requirement.

C has different data types for different types of data and can be broadly classified as :

  1. Primary data types
  2. Secondary data types

Primary data types consist following data types.

Data Types in C

Integer types:

Integers are whole numbers with a range of values, range of values are machine dependent. Generally an integer occupies 2 bytes memory space and its value range limited to -32768 to +32767 (that is, -215 to +215-1). A signed integer use one bit for storing sign and rest 15 bits for number.
To control the range of numbers and storage space, C has three classes of integer storage namely short int, int and long int. All three data types have signed and unsigned forms. A short int requires half the amount of storage than normal integer. Unlike signed integer, 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. The long integers are used to declare a longer range of values and it occupies 4 bytes of storage space.

Syntax: int <variable name>; like
int num1;
short int num2;
long int num3;

Example: 5, 6, 100, 2500.

Integer Data Type Memory Allocation

Floating Point Types:

The float data type is used to store fractional numbers (real numbers) with 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 double to define the number. The double is same as float but with longer precision and takes double space (8 bytes) than float. To extend the precision further we can use long double which occupies 10 bytes of memory space.

Syntax:          float <variable name>; like
float num1;
double num2;
long double num3;

Example:      9.125, 3.1254.

Floating Point Data Type Memory Allocation

Character Type:

Character type variable can hold a single character. As there are singed and unsigned int (either short or long), in the same way there are signed and unsigned chars; both occupy 1 byte each, but having different ranges. Unsigned characters have values between 0 and 255, signed characters have values from –128 to 127.

Syntax: char <variable name>; like
char ch = ‘a’;

Example:      a, b, g, S, j.

Void Type:

The void type has no values therefore we cannot declare it as variable as we did in case of integer and float.

The void data type is usually used with function to specify its type. Like in our first C program we declared “main()” as void type because it does not return any value. The concept of returning values will be discussed in detail in the C function hub.

User defined type declaration

C language supports a feature where user can define an 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>; like
typedef int number;

Now we can use number in lieu of int to declare integer variable. For example: “int x1” or “number x1” both statements declaring an integer variable. We have just changed the default keyword “int” to declare integer variable to “number”.

C Programming Language (2nd Edition)
Amazon Price: $35.64
List Price: $67.00
Programming in C (3rd Edition)
Amazon Price: $24.00
List Price: $49.99
Absolute Beginner's Guide to C (2nd Edition)
Amazon Price: $19.00
List Price: $39.99
C Programming: A Modern Approach, 2nd Edition
Amazon Price: $59.31
C Primer Plus (5th Edition)
Amazon Price: $30.63
List Price: $54.99
C All-in-One Desk Reference For Dummies
Amazon Price: $19.87
List Price: $34.99

Data Types in C, Size & Range of Data Types.

C language supports various data types, this charts shows you how much space each data type like int, char, float occupies space in memory along with its data range and keyword used by programmer in C program.
C language supports various data types, this charts shows you how much space each data type like int, char, float occupies space in memory along with its data range and keyword used by programmer in C program.

Comments

sreeemay 3 years ago

ur tought is so good try to write some other programms and refference books

nicomp 3 years ago

An enum is an integer type.

fahad 2 years ago

what is boolean in data type

rajkishor09 2 years ago

blooean is also a data type which can hold value like true or false (0 or 1). But boolean is not supported in C, boolean is supported in languages like C#, PHP, etc.

muniba 2 years ago

well this site is really useful n had helped me a lot in solving my confusions n doubts

pappu 2 years ago

love u

Saurabh 2 years ago

Dear Raj, You have introdeced educational topic in hub pages. All the Best Carry on.

Raj 2 years ago

good One!

K.S.KHAN 2 years ago

ITS HELPING ME IN MY ASSIGNMENT,I HOPE IT WORKS TOO.....

Zulekha Sarfaraz 2 years ago

Well, it sure is useful

ankur gupta 2 years ago

nice one

josh 2 years ago

Its very useful for quick reference also............. Great work

suman 2 years ago

what is c progamming

rani  2 years ago

what is c

sushiltl 2 years ago

thats really gud hub for those who are in learning stage of c

soumya 2 years ago

i love u c

tayyab 2 years ago

i like programming

swapnali 2 years ago

is the value & reference is the basic data types of C???????

save my system 2 years ago

C is the basic programming language. If You are comfortable with C, then only you can able to learn more advance programming skills. I found above mention article on C very basic, but more important from the beginners point of view. Thanks for sharing it. This article surely reduces unnecessary fear of the computer language.

suji 2 years ago

HI this is nice one.but i didnt know "is structure is userdefined datatype or not?"please reply to this

naheed 2 years ago

c language:its veeeeeeeeeeeeeeery dificult.

mustafa 24 months ago

thanks

Tahir Ali 24 months ago

Dear

In this web i get good knowledge but text size little bit problem so plz text size should be large.

jas 23 months ago

Category Type Description Example

Reference object The ultimate base type of all other types object o = new Stack();

Reference string String type; a string is a sequence of Unicode characters string s = “Hello”;

value – int sbtype 8-bit signed integral type sbyte val = 12;

value – int short 16-bit signed integral type sgort val = 12;

value – int int 32-bit signed integral type int val = 12;

value – int long 64-bit signed integral type long val1 = 12;

long val2 = 34L;

value – int byte 8-bit unsigned integral type byte val1 = 12;

byte val2 = 34U;

value – int ushort 16-bit unsigned integral type ushort val1 = 12;

ushort val2 = 34U;

value – int uint 32-bit unsigned integral type uint val1 = 12;

uint val2 = 34U;

value – int ulong 64-bit unsigned integral type ulong val1 = 12;

ulong val2 = 34U;

ulong val3 = 56L;

ulong val4 = 78UL;

value – float float Single-precision floating point type float value = 1.23F;

value – float double Double-precision floating point type double val1 = 1.23

double val2 = 4.56D;

value – bool bool Boolean type; a bool value is either true or false bool value = true;

value – chat char Character type; a char value is a Unicode character char value = ‘h’;

value – decimal decimal Precise decimal type with 28 significant digits decimal value = 1.23M;

anjali 23 months ago

I feel ,like it it's importand from the biginners

prathibha 23 months ago

thank you

RAJ 23 months ago

if want to increase text size just press "ctrl+" in any browser

rima 23 months ago

i want all the knowledege of the c i donnt knw anything

muzammil3 22 months ago

If any one have any good material regarding c & c++,plz send me at muzammil3@gmail.com

Raghava 22 months ago

I like programming but it confusing to me.

Mitali 21 months ago

Thanx dear raj..... i dont know wt is data type..... thanx 4 the information.............

again thanx..........

mitali 21 months ago

hey raj your integer value is wrong.......

it is -32768 to +32767.......

nidhi 21 months ago

it's good but so boring...

hitender 20 months ago

hello can i know about the data type in c

bansal 20 months ago

check the range of floats again

Siva 20 months ago

Could you explain clearly why sizeof(void) returns 1?

Dennis 20 months ago

I wanted a quick overview of the difference between primary and secondary data types and your diagrams have done just that. Thanks!

Immanuel 20 months ago

This is the first time iam using it....it may be helpful...to me....hope that..it may also be useful..for my further..computer assignments...

srinivas 20 months ago

sir,

i donot understand char is 1 byte but the range is -127to 128

it occupies memory only 8 bit but the range of character are 128. please explain this

anita priyanka 20 months ago

bakwasssssssssss

sonia 20 months ago

so boringgggggggggggggggg

ashraf 20 months ago

thank you for this.it is very useful & i expect more so pls give more information with simple programs

fayazali 19 months ago

what is getch(); why we use it

little 19 months ago

thank you for this.it is very useful & i expect more so pls give more information with simple programs

19 months ago

hey what is recursion??

REEAk 19 months ago

i lyk c programming

venu 19 months ago

short int hold only 1 byte of storage

khan 19 months ago

great work

UMAIR KHAN 19 months ago

That site is much helpful for my engineering work.i like it............

hidayat shigri 19 months ago

nice dear i feel good ,,,,,,,,,,and find useful answers

rajiv 19 months ago

k dear..................................... not so bad................................

shahbaaz khan 19 months ago

it is good for baisc knoladge.

kiran 19 months ago

its amazing

karthik 19 months ago

Its vry gd 4 my studies

gixmo wixmo 18 months ago

i'm startin to lyk programming w e help of websites lyk this one even e sky aint e limit.thank u.

donia 18 months ago

Wa OOOOOOOOOO its excellant notes it solve all my problem in seconds thanx to writer

kisarei 18 months ago

hope to be helped to further c knowledge.

diego 18 months ago

ehhh!!!! wala koy nasabtan!

priya 18 months ago

ohhhhhhhhhhhhhhhhhhhhhhh its tooooooooooooo hard reyyyyyyyyyyyyyyy

Krishnasai 18 months ago

wt is double and where we use it and wt is the difference between double and other datatypes

tracy 18 months ago

nice one

Krishnasai 18 months ago

Wt is typedef?

Sreenu 18 months ago

It is very good. But please provide information about linked list.

tiya 18 months ago

it's nice

*raji* 18 months ago

in integer data type the size of int is wrongly printed it is 4 bytes not 2 bytes

james 18 months ago

i did not understand your explanation

vinod mathrani 18 months ago

i understand but data type is much clear to me

amazing text..............

ajay 18 months ago

c ccccccccccccccccccccccccccccccccccccccccccc dccccccccccccccccccc

TINA 18 months ago

Please give samples on Structures in Turbo C++

ammulu 18 months ago

please tell me how to find the power of integers in C language?

Sri 18 months ago

answer for power any integer

#include

#include // we use the command with cc name of file -lm in ubuntu system

main()

{

int y;

int m,n;

puts("Enter your number");

scanf("%d%d",&m,&n);

y=pow(m,n);

printf("%d\n",y);

}

andrie 18 months ago

tang ina nyong lahat !!!

siva 17 months ago

doubt means ask me...i very expert...

narendra yadav 17 months ago

hi its good job if u have any then call me

naveenkumar 17 months ago

c is an very beautiful language

rahul 17 months ago

i m impressed by ths

rajib 17 months ago

thanks for all

jatinder 17 months ago

its great

bhargav 16 months ago

nice

farhana naaz ansari 16 months ago

thank u for helping me

aneel 16 months ago

thanks..........

shohel 16 months ago

thanks For Help.

Voruganti Naveeen Kumar 16 months ago

pls explain typedef concept

SHASHI KANT SHUKLA 15 months ago

i saw but it is not so comfortable

renuka phanindra 15 months ago

excellent in c

sara 15 months ago

nice

Sarfaraz Alam  15 months ago

C IS PROCEDER LANGUAGE AND SECURE AND FLEXIBLE AND ASSEMBLY LAGUAGE. AND C IS SECONED GENERATION LANGUAGE WHICH IS WIDLEY USED IN THIS WORLD FIRST B LANGUAGE WAS DEVELOPED BY KEN THOMPSON WHICH WAS FULL SUPPORTABLE ON MCHINE AND IN THIS LANGUAGE SOME KEYBORD THAT NOBADY KNOWS.

AND AFTER SOME TIME DINEIC SICHEE EXPANDE THESE LANGUAGE IN C LANGUAGE.

AJODHIA 15 months ago

INTEGER HAVE 2 BYTE AND LONG HAVE 4 AND SHORT IS ONE WHY SHORT RANGE IS -32768 TO -32767 WHY ITS NOT EQUAL -128 TO 127

AJODHIA

kishore 15 months ago

thanks sir for this article.....

now i wud b able to complete my assingment

premnath 15 months ago

hai. how to declare string in c program

filza khan 15 months ago

what is ERROR in C programming language?

karteek.m 15 months ago

nice 2 study

Mary Grace Gabi 15 months ago

Great! I got it....

Nice site...all you want to know is in here and very understandable

Mary Grace Gabi 15 months ago

Great! I got it....

Nice site...all you want to know is in here and very understandable

dilip singh 15 months ago

without variable declare we done c programming?

G NAGARAJA 14 months ago

VERYGOOD IN C VERY USEFULL FOR USERS

bhaskar 14 months ago

its not bad, some more programms examples

nitheesh 13 months ago

it is easy to learn this program

nitheesh mettupalayam 13 months ago

easy to study

Kilari renuka 13 months ago

iluc

zain Malik  13 months ago

good work on dis site.

pkkumarpawan41@gmail.com 13 months ago

i visit dis site on 22nd april 2011,and as a compuer science student i fill that he has done better and it in easily understable language.

(m from bihar,patna,bihta,jinpura)

taimoor 12 months ago

very nice work i like it

abhinaya 12 months ago

I like the work very much ! people who are reading atleast try to understand it!!

Hasini 12 months ago

Need in depth details of range values

jagadeesha 11 months ago

so nice

ehc 11 months ago

nice one :)

apurva 11 months ago

which keyword is used in combination with a valid C data type to redefine the name of the data type?

priya 10 months ago

help me alot in ma c asignment thanx

kamla kant pandey 10 months ago

destructor can be called finalize or not in the java?

supreet 10 months ago

thanks...for quick reference sir..:)

asma 10 months ago

it is very imp for inetual learners

dolly 10 months ago

it is very good and helped me alot

nitya 10 months ago

nice....it helped me alot for my seminar............

balu.... 10 months ago

nice answer

sidzy 9 months ago

what are compiler directives?

fida 9 months ago

i like this theory because this i understand.thanks

chinky 9 months ago

so boring

sarab 9 months ago

what is the best book of c????????????

vitthal 9 months ago

it is very simple if we understand properly

Jay 9 months ago

The best books..Oo..there are many

but you can refer to "Let Us C"-Yashwant kantentar OR

"C Programming \"-Balaguruswamy

sheetal 9 months ago

its realy good...i hav prepare my assignment using it..hop so i wil get gud rank..

pramod 9 months ago

it's good.

ashish panwar 9 months ago

it is very useful for bca group...............

i am student of bca .....

and i like this sheet.......

Munna 9 months ago

It is very simple language

viky 9 months ago

nice site

shipra 9 months ago

y do memory allocated to different data types of c are in even terms not in odd terms?

Maulik Patel 9 months ago

how can I do programming in IC?

Pls tell me......

Raj 9 months ago

explian data type in detial

manisha 9 months ago

thxxxxxxxxxx for this usefull inforamtion

Muttant 9 months ago

Cool!!

Ritika 9 months ago

hey ...i din get the point...that, Unsigned characters have values between 0 and 255, signed characters have values from –128 to 127. what does this means actually.plz elaborate.

Ranjan 9 months ago

signed intteger take both +ve and -ve value but unsigned integer take only +ve value

aakash 8 months ago

hey sir, the spelling of integer is wrong, in the table data types in c

prakash 8 months ago

how can we extend the range of values?????

MAAHI 8 months ago

IT IS VERY GOOD, BT FLOAT AND DOUBLE RANGES ARE NT UNDERSTABLE

devender 8 months ago

it;s very helpful to the new commers to the computer sites

alusha 8 months ago

it help me to prepare my practical so it is so helpful to me

kishorekumar 8 months ago

boss thank u very much it is very much useful

kishorekumar 8 months ago

boss thank u very much it is very much useful

krishna 8 months ago

..very helpful for beginers of c programming

Mayank Singh Kanaujia 8 months ago

its really a nyc aproch..i appreciate it and just keep it up....

SWEETY 8 months ago

ANY OTHER KEY WORDS ARE THERE EXPECT 32

nmyfvcgb 8 months ago

c languge is jadhal programing

debryan 8 months ago

can you please tell me how can i create my own data type of 256MB memory space

please reply ASAP at my e-mail id makhija2prakhar@live.com

kunal 8 months ago

its nice prestation of data type

Priya 8 months ago

What does E in 1.2E-38 refers to?

p k sharma 8 months ago

your method is very right

wantedmaniac 8 months ago

Thanks Mann . .

Perfectly Explained . .

Naresh 8 months ago

Thanks you help me to solving a problem.....

Anu 8 months ago

its nice

pravallika 8 months ago

so useful

Girish 8 months ago

thanks brthr

manoj 8 months ago

thanks

varun dhyani 7 months ago

sir plz describe the definition of int,float,char,double,void,

array,function,pointer

structure,unions,enumerations,

manoj dhyani 7 months ago

thank u..............

mani 7 months ago

i u c

Ahsan 7 months ago

T hank's Dear friend

vishakha 7 months ago

thank you for provide the c

pooja madivalar 7 months ago

thank u as its helpi me kno better

Ashish 7 months ago

Its not enough pls gv sm extra details abt c

andersonkibet 7 months ago

thanx i have learnt alot.

aqsa 7 months ago

c language is very good becuse i understand it very easily.

Nik's 7 months ago

Thank U All Friend

vimal 7 months ago

size of int,short,long,float and double

are archetecture dependent

sameer 7 months ago

some month before i dont know any inf in c

PANKAJ DWIVEDI 7 months ago

C is the basic programming language. If You are comfortable with C, then only you can able to learn more advance programming skills. I found above mention article on C very basic, but more important from the beginners point of view. Thanks for sharing it. This article surely reduces unnecessary fear of the computer language.

shaju 7 months ago

nice program

hari 7 months ago

koope

twinkle 7 months ago

i hate c i don't like 'c' language okkkkkkkkkkk

tamanna 7 months ago

too difficult and bkkwwaaaaaaaaasss

rahul 7 months ago

i want to know about c, its very intresting, but also hard for me.

sajan 7 months ago

i love c programming its very useful.

sajan 7 months ago

i luve studyin c programming. studying

suyash47 7 months ago

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,...

Karan 7 months ago

Thanks.....Raj

vallabhi 6 months ago

love U C................Learning U is just playing with a friend

Syed Zaheer 6 months ago

This web side is awesome, i got good notes for c n have also learn answers soo tnks

teja 6 months ago

what is the use of %u in c language

Parvez 6 months ago

Why dos integer datatype in c take 4 bytes in visual studio ?

plsss reply back!!!

ruji 6 months ago

what is c plz tell me ....

rajkishor09 6 months ago

@Parvez size of any data type is compiler dependent.

srinu 6 months ago

if we have an intrest, then can we learn this subject very easily,,,,,

Ravi 6 months ago

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.

m kashif 6 months ago

simple but easy to understand. so execelent

chinni 6 months ago

its very nice & easy to understand if da logics are clear

sai ram 6 months ago

i know c but i dont knw.... c language wt to do....bro... i beg u teachh c plz bro i touch u r feet..... my num is 9000932558

sai ram 6 months ago

i m from b v raju college,studying 1st year,narsapur,medak.

.....please teach me c bro....

ravi 6 months ago

@ sai ram

which branch r u ??

mohd kashif 6 months ago

great work

fasial 6 months ago

its support very well for my exam

faizkiki family 6 months ago

thank u

dinesh 6 months ago

thank u very much i answered my viva question in my practical session by using this site

jhin_jhin 6 months ago

i liKe it.

nikhil so.... 6 months ago

thank u very much ...:)

chitti 6 months ago

gud expl

chitti 6 months ago

thnk u

chitti 6 months ago

thnk u bro 4 such a good expl

chitti 6 months ago

i gave a seminar using this

Sunti Lhatdavong 6 months ago

I like C language

all bca 6 months ago

c language is so so so so so so easier dude

cheryl 6 months ago

what is the importance of the sizes of the data types in c language?

prince suwalka 6 months ago

c lang is very mindblowing lang

yasir lovee 6 months ago

ThankU sir,,,

Jst a question that U have not used in data types that is ''Format'' of these data types.Plz justify if so........

Vamshi 6 months ago

Nice site bro..

It is very use full...

mobigujjar 5 months ago

I m a stdnt of BS(IT)

plz u help me in this field

plz snd email address to me

mobigujjar02@gmail.com

Raj 5 months ago

am a student of cse but from bio background so plz help me my email id is-rajnandi15992@gmail.com

adil khan 5 months ago

no compiler not depend on variable..........

bk 5 months ago

Too nice sis it is very koalaveru da

arvnagendrakumar5 5 months ago

i love c programs

codeguru 5 months ago

this article is so so not good

krish 5 months ago

very fine historical and briefly knowledge of c. good one

aruna devi 5 months ago

what are data types in c?

glorious143@hotmail.com 5 months ago

what's the mean by recursion?

kamaluddin ahmed 5 months ago

i want to make indian national flag but how ,i have no idea ,please give me some tips

sanjeev kumar 5 months ago

i am define int a=015 and print the value is 13 why plz rply me urgently

Sanket Sathe 5 months ago

Awesum...

kanchan Pande 4 months ago

Can any one tell me,that there are how many data types included in C and C#.

md wakash ahmad 4 months ago

why uses # in c program

please reply this topic on that site

Nibedita Swain 4 months ago

What variable? explane pointer variable

saanraja@yahoo.com 4 months ago

thankyou very much...............this provides us many hints for further study

supriya,s.p.jain college 4 months ago

thank's for deeply information

dude 4 months ago

how can i print these data types i mean like %d for integer... what for double, long double and short int etc

INSI 4 months ago

WAT IS USE OF * IN SCANF STATEMAENT?

Md Ali Umar 4 months ago

for double %lf & for long double %Lf, for short signed int %d, short unsigned int %u.

aliumar.in@gmail.com

Bhagalpur,

Bihar,

India.

sree 4 months ago

i dont know c.how to do the programs,so plz give me a suggestion to over come the problem

fahad akhtar 4 months ago

plzzzz give me about the idea of modulus in algorithm

ravi ranjan 4 months ago

gooooooooooddddd

kalpana 3 months ago

so confuse and so boring

Ajay PAtil 3 months ago

@rajkishor09 ::::::::::::::?????????????????

if knw the correct ans den only post otherwise dont post..............dont 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 dont post

Ajay bidhauliya 3 months ago

need to few is described

mekhzam 3 months ago

this is very nice

raj 3 months ago

why we need range for datatype like int as -32708 to 32627?

santhosh kumar 3 months ago

it's intresting..... but i dnt know c program.....

pls help me....

anchal 3 months ago

kuch samajh nah araha

jaswant kumar 3 months ago

i think four batter c program tools this web site

ankur 3 months ago

can u tell me where the data type store in comp.memory

Java Programs 3 months ago

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 :

http://javaprograms.hubpages.com/hub/Introduction-

have a look .... Thanks for the wonderful information...

priyanka 2 months ago

Thanks, it helps me alot

Arun Mavi 2 months ago

It is hard for UP board students only otherwise it is easy

monisha 2 months ago

what is abstract datatype?

Ramisha Rukhsar 2 months ago

plz tell me about the problems of floating point used in c programming language.plz tell me ans as soon as possible

Hasnain 2 months ago

If any one have any good material regarding c & c++,plz send me at shasnainraza92@aol.com

magoo 2 months ago

that was short and precise, thank you!

abhinav vats 8 weeks ago

it is very helpfull so plz keep it up

simran 7 weeks ago

thanks for uploading this information

really its very help me

Masabo Christophe 5 weeks ago

thank you for teaching, then you add more programms

ok

waqas Amanat 3 weeks ago

its really a very helpful for students & others. it helped me alot in my exams..thankx alot

rajkishor09 3 weeks ago

thanks for visiting my friend...

Submit a Comment
Members and Guests

Sign in or sign up and post using a hubpages account.



    Like this Hub?
    Please wait working