C Programming Lesson - Data Types in C Language
By rajkishor09
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 :
- Primary data types
- 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.
Secondary Data Types
- Arrays in C Programming (Read it now)
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,... - Pointers in C Programming (Read it now)
In this tutorial I am going to discuss what pointer is and how to use them in our C program. Many C programming learner thinks that pointer is one of the difficult topic in C language but its not... - Structure in C Programming (Read it now)
We used variable in our C program to store value but one variable can store only single piece information (an integer can hold only one integer value) and to store similar type of values we had to declare...
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”.
|
|
ABEKA 6th GRADE LANGUAGE C SET OF 4 BOOKS SAVE $$
Current Bid: $46.21
|
|
|
C Programming Language (2nd Edition) (Prentice Hall Software)
Current Bid: $27.48
|
|
|
Sonlight Language Arts 4 & 5 IG Instructor's Guide c2011 with 16 books
Current Bid: $125.00
|
|
|
C Programming Language by Dennis M. Ritchie and Brian W. Kernighan
Current Bid: $14.95
|
| No Photo |
Pro LINQ: Language Integrated Query in C# 2010 - Paperback
Current Bid: $16.19
|
| No Photo |
The C++ Programming Language by Bjarne Stroustrup (1986, Paperback)
Current Bid: $.99
|
Data Types in C, Size & Range of Data Types.
C programming tutorial links
- String in C Programming Language
String in C is collection of characters whereas character (char) in C is a single alphabet and programming in C is incomplete if you don’t have any idea about string declaration, initialization and reading string from keyboard. So in this C language - Call by Value and Call by Reference in C Programming
Call by value and call by reference is the most confusing concept among new C language programmer. I also struggled with this, the reason may be my teacher is not explaining it in simple words or I was dumb. Whatever the reason is; here I will try to - The C Programming Language - Brief History
Before we start any complex program in C, we must understand what really C is, how it came into existence and how it differs from other languages of that time. In this tutorial I will try to talk about these... - C Programming Lesson - Basic Virtual Keyboard Application
To accomplish this task you dont need to buy any expensive software or hardware, only a little knowledge of C program will do and you can build your own musical keyboard software. Before we begin you... - Looping in C Programming Language, It's Types and Example
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 - How While loop Works in C Programming Language
I already explained what is loop and why we use loop in c language, and I am not going to repeat that here again. So we will start with while loop explanation. While loop is one of the simple loop available in C language.It’s very easy to use, lets c - How For Loop Works in C Programming Language
Along with while loop and do-while loop, for loop is also part of C programming language. For many programmers, for loop seems to be easiest loop comparing other two loops (while and do-while loop). Mainly its structure (syntactically) makes it easy - C Programming Lesson - Do While Loop and Difference Between While and Do While Loop
If you are looking for what is loop and why we use loop in c language then you can check my article on that topic. This article is entirely dedicated to do-while loop and its usage. I must tell you that do-while loop is similar to while loop but only - Swap two variables without using third variable in C , C# and Java
This article explains how we can swap variable values without using third variable. There are different ways to do so and I tried including all know methods. You can get code in C, Java and C# language..... - C Programming Lesson - Function in C
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 ... - C Programming Lesson - Types of Function
In my previous c programming tutorial I tried to explain what the function, its advantages is and how to declare a C function. And I told you that there are five types of functions and they are: ... - C Programming Lesson - Arrays
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,... - 2 Dimensional Array in C Programming Language
We know how to work with an array (1D array) having one dimension. In C language it is possible to have more than one dimension in an array. In this tutorial we are going to learn how we can use two... - C Programming Lesson - Multidimensional array (3D Array)
C allows array of two or more dimensions and maximum numbers of dimension a C program can have is depend on the compiler we are using. Generally, an array having one dimension is called 1D array, array... - C Programming Lesson - File Copy Program in C
Today we are going to learn a simple file copy program in C language. As I said this is a simple file copy program so you should not expect its output like DOS copy command has. Ok lets start. The main...
Other articles
- How to Setup Mobile Phone Internet using Nokia, Samsung Mobile Phone on Laptop and PC
If your mobile have internet connection available then you can use it on laptop or desktop for PC internet access. There are few things we require before we can proceed to actual configuration. Firstly a mobile phone having modem facility, mobile ser - How to share an internet connection on LAN?
- Setup LAN with Hub or Switch (color coding provided)
- How to Search on Google - Google Tricks For Improving Search Results
Google is one of the best search and million and billion searches is being done on daily basis. But you know you can improve Google search result to get what you exactly want. In this article I am going to give you Google tricks list which will give
Comments
An enum is an integer type.
what is boolean in data type
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.
well this site is really useful n had helped me a lot in solving my confusions n doubts
love u
Dear Raj, You have introdeced educational topic in hub pages. All the Best Carry on.
good One!
ITS HELPING ME IN MY ASSIGNMENT,I HOPE IT WORKS TOO.....
Well, it sure is useful
nice one
Its very useful for quick reference also............. Great work
what is c progamming
what is c
thats really gud hub for those who are in learning stage of c
i love u c
i like programming
is the value & reference is the basic data types of C???????
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.
HI this is nice one.but i didnt know "is structure is userdefined datatype or not?"please reply to this
c language:its veeeeeeeeeeeeeeery dificult.
thanks
Dear
In this web i get good knowledge but text size little bit problem so plz text size should be large.
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;
I feel ,like it it's importand from the biginners
thank you
if want to increase text size just press "ctrl+" in any browser
i want all the knowledege of the c i donnt knw anything
If any one have any good material regarding c & c++,plz send me at muzammil3@gmail.com
I like programming but it confusing to me.
Thanx dear raj..... i dont know wt is data type..... thanx 4 the information.............
again thanx..........
hey raj your integer value is wrong.......
it is -32768 to +32767.......
it's good but so boring...
hello can i know about the data type in c
check the range of floats again
Could you explain clearly why sizeof(void) returns 1?
I wanted a quick overview of the difference between primary and secondary data types and your diagrams have done just that. Thanks!
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...
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
bakwasssssssssss
so boringgggggggggggggggg
thank you for this.it is very useful & i expect more so pls give more information with simple programs
what is getch(); why we use it
thank you for this.it is very useful & i expect more so pls give more information with simple programs
hey what is recursion??
i lyk c programming
short int hold only 1 byte of storage
great work
That site is much helpful for my engineering work.i like it............
nice dear i feel good ,,,,,,,,,,and find useful answers
k dear..................................... not so bad................................
it is good for baisc knoladge.
its amazing
Its vry gd 4 my studies
i'm startin to lyk programming w e help of websites lyk this one even e sky aint e limit.thank u.
Wa OOOOOOOOOO its excellant notes it solve all my problem in seconds thanx to writer
hope to be helped to further c knowledge.
ehhh!!!! wala koy nasabtan!
ohhhhhhhhhhhhhhhhhhhhhhh its tooooooooooooo hard reyyyyyyyyyyyyyyy
wt is double and where we use it and wt is the difference between double and other datatypes
nice one
Wt is typedef?
It is very good. But please provide information about linked list.
it's nice
in integer data type the size of int is wrongly printed it is 4 bytes not 2 bytes
i did not understand your explanation
i understand but data type is much clear to me
amazing text..............
c ccccccccccccccccccccccccccccccccccccccccccc dccccccccccccccccccc
Please give samples on Structures in Turbo C++
please tell me how to find the power of integers in C language?
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);
}
tang ina nyong lahat !!!
doubt means ask me...i very expert...
hi its good job if u have any then call me
c is an very beautiful language
i m impressed by ths
thanks for all
its great
nice
thank u for helping me
thanks..........
thanks For Help.
pls explain typedef concept
i saw but it is not so comfortable
excellent in c
nice
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.
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
thanks sir for this article.....
now i wud b able to complete my assingment
hai. how to declare string in c program
what is ERROR in C programming language?
nice 2 study
Great! I got it....
Nice site...all you want to know is in here and very understandable
Great! I got it....
Nice site...all you want to know is in here and very understandable
without variable declare we done c programming?
VERYGOOD IN C VERY USEFULL FOR USERS
its not bad, some more programms examples
it is easy to learn this program
easy to study
iluc
good work on dis site.
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)
very nice work i like it
I like the work very much ! people who are reading atleast try to understand it!!
Need in depth details of range values
so nice
nice one :)
which keyword is used in combination with a valid C data type to redefine the name of the data type?
help me alot in ma c asignment thanx
destructor can be called finalize or not in the java?
thanks...for quick reference sir..:)
it is very imp for inetual learners
it is very good and helped me alot
nice....it helped me alot for my seminar............
nice answer
what are compiler directives?
i like this theory because this i understand.thanks
so boring
what is the best book of c????????????
it is very simple if we understand properly
The best books..Oo..there are many
but you can refer to "Let Us C"-Yashwant kantentar OR
"C Programming \"-Balaguruswamy
its realy good...i hav prepare my assignment using it..hop so i wil get gud rank..
it's good.
it is very useful for bca group...............
i am student of bca .....
and i like this sheet.......
It is very simple language
nice site
y do memory allocated to different data types of c are in even terms not in odd terms?
how can I do programming in IC?
Pls tell me......
explian data type in detial
thxxxxxxxxxx for this usefull inforamtion
Cool!!
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.
signed intteger take both +ve and -ve value but unsigned integer take only +ve value
hey sir, the spelling of integer is wrong, in the table data types in c
how can we extend the range of values?????
IT IS VERY GOOD, BT FLOAT AND DOUBLE RANGES ARE NT UNDERSTABLE
it;s very helpful to the new commers to the computer sites
it help me to prepare my practical so it is so helpful to me
boss thank u very much it is very much useful
boss thank u very much it is very much useful
..very helpful for beginers of c programming
its really a nyc aproch..i appreciate it and just keep it up....
ANY OTHER KEY WORDS ARE THERE EXPECT 32
c languge is jadhal programing
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
its nice prestation of data type
What does E in 1.2E-38 refers to?
your method is very right
Thanks Mann . .
Perfectly Explained . .
Thanks you help me to solving a problem.....
its nice
so useful
thanks brthr
thanks
sir plz describe the definition of int,float,char,double,void,
array,function,pointer
structure,unions,enumerations,
thank u..............
i u c
T hank's Dear friend
thank you for provide the c
thank u as its helpi me kno better
Its not enough pls gv sm extra details abt c
thanx i have learnt alot.
c language is very good becuse i understand it very easily.
Thank U All Friend
size of int,short,long,float and double
are archetecture dependent
some month before i dont know any inf in c
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.
nice program
koope
i hate c i don't like 'c' language okkkkkkkkkkk
too difficult and bkkwwaaaaaaaaasss
i want to know about c, its very intresting, but also hard for me.
i love c programming its very useful.
i luve studyin c programming. studying
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,...
Thanks.....Raj
love U C................Learning U is just playing with a friend
This web side is awesome, i got good notes for c n have also learn answers soo tnks
what is the use of %u in c language
Why dos integer datatype in c take 4 bytes in visual studio ?
plsss reply back!!!
what is c plz tell me ....
@Parvez size of any data type is compiler dependent.
if we have an intrest, then can we learn this subject very easily,,,,,
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.
simple but easy to understand. so execelent
its very nice & easy to understand if da logics are clear
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
i m from b v raju college,studying 1st year,narsapur,medak.
.....please teach me c bro....
@ sai ram
which branch r u ??
great work
its support very well for my exam
thank u
thank u very much i answered my viva question in my practical session by using this site
i liKe it.
thank u very much ...:)
gud expl
thnk u
thnk u bro 4 such a good expl
i gave a seminar using this
I like C language
c language is so so so so so so easier dude
what is the importance of the sizes of the data types in c language?
c lang is very mindblowing lang
ThankU sir,,,
Jst a question that U have not used in data types that is ''Format'' of these data types.Plz justify if so........
Nice site bro..
It is very use full...
I m a stdnt of BS(IT)
plz u help me in this field
plz snd email address to me
mobigujjar02@gmail.com
am a student of cse but from bio background so plz help me my email id is-rajnandi15992@gmail.com
no compiler not depend on variable..........
Too nice sis it is very koalaveru da
i love c programs
this article is so so not good
very fine historical and briefly knowledge of c. good one
what are data types in c?
what's the mean by recursion?
i want to make indian national flag but how ,i have no idea ,please give me some tips
i am define int a=015 and print the value is 13 why plz rply me urgently
Awesum...
Can any one tell me,that there are how many data types included in C and C#.
why uses # in c program
please reply this topic on that site
What variable? explane pointer variable
thankyou very much...............this provides us many hints for further study
thank's for deeply information
how can i print these data types i mean like %d for integer... what for double, long double and short int etc
WAT IS USE OF * IN SCANF STATEMAENT?
for double %lf & for long double %Lf, for short signed int %d, short unsigned int %u.
aliumar.in@gmail.com
Bhagalpur,
Bihar,
India.
i dont know c.how to do the programs,so plz give me a suggestion to over come the problem
plzzzz give me about the idea of modulus in algorithm
gooooooooooddddd
so confuse and so boring
@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
need to few is described
this is very nice
why we need range for datatype like int as -32708 to 32627?
it's intresting..... but i dnt know c program.....
pls help me....
kuch samajh nah araha
i think four batter c program tools this web site
can u tell me where the data type store in comp.memory
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...
Thanks, it helps me alot
It is hard for UP board students only otherwise it is easy
what is abstract datatype?
plz tell me about the problems of floating point used in c programming language.plz tell me ans as soon as possible
If any one have any good material regarding c & c++,plz send me at shasnainraza92@aol.com
that was short and precise, thank you!
it is very helpfull so plz keep it up
thanks for uploading this information
really its very help me
thank you for teaching, then you add more programms
ok
its really a very helpful for students & others. it helped me alot in my exams..thankx alot
thanks for visiting my friend...






sreeemay 3 years ago
ur tought is so good try to write some other programms and refference books