ArtsAutosBooksBusinessEducationEntertainmentFamilyFashionFoodGamesGenderHealthHolidaysHomeHubPagesPersonal FinancePetsPoliticsReligionSportsTechnologyTravel
  • »
  • Technology»
  • Computers & Software»
  • Computer Science & Programming

C Programming Lesson - Data Types in C Language

Updated on September 29, 2014

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 :

  1. Primary data types
  2. Secondary data types

Data Types in C

Primary Data Types in C Language

Primary data types include the following:

  • Integer
  • Float
  • Character
  • Void

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:

  1. short int
  2. int
  3. 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
int num1;
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>;

float num1;
double num2;
long double num3;

Example: 9.125, 3.1254.

Floating Point Data Type Memory Allocation

Memory allocation of float data in C.
Memory allocation of float data in C.

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

This chart shows you how much space each data type like int, char, float occupies in memory, along with its data range and the keyword used by the C programmer.
This chart shows you how much space each data type like int, char, float occupies in memory, along with its data range and the keyword used by the C programmer.

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.


    0 of 8192 characters used
    Post Comment

    • profile image

      Obzy 12 months ago

      What is the size and range of viod

    • profile image

      diksha koushal 3 years ago

      its nice

    • nicomp profile image

      nicomp really 3 years ago from Ohio, USA

      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.

    • profile image

      Aadil Syed 3 years ago

      awesom programing c but its vry complicated......

    • profile image

      nikita 4 years ago

      thanks for information

    • profile image

      ss 4 years ago

      its nice

    • profile image

      mushkin 4 years ago

      thanks its very easy to understand,not any confuse

    • profile image

      rajendra 5 years ago

      please give me all notes of c langauge with programme........

    • profile image

      manjunath 5 years ago

      its very useful to students thank u

    • profile image

      udhayan 5 years ago

      than q very much....this helped me a lot:)))

    • profile image

      sania angle 5 years ago

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

    • rajkishor09 profile image

      RAJKISHOR SAHU 5 years ago from Bangalore, Karnataka, INDIA

      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 I didn't know know that I am so good in copying content :P.

    • profile image

      sonuxrt 5 years ago

      Don't copy from another website

    • Programminghub profile image

      Programminghub 5 years ago from India

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

    • profile image

      ALI 5 years ago


    • profile image

      Pinku Hazra 5 years ago

      By this answer am very helpful,..thanks keep on.

    • profile image

      ramesh 5 years ago


    • profile image

      ian05 5 years ago

      very helpful... keep it up, do some more... great job.

    • profile image

      jhezrylle 6 years ago

      anu po ung mga Variables ng c language?/

    • profile image

      jawadmalik 6 years ago

      its working ... :)

    • rajkishor09 profile image

      RAJKISHOR SAHU 6 years ago from Bangalore, Karnataka, INDIA

      thanks for visiting my friend...

    • profile image

      waqas Amanat 6 years ago

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

    • profile image

      Masabo Christophe 6 years ago

      thank you for teaching, then you add more programms


    • profile image

      simran 6 years ago

      thanks for uploading this information

      really its very help me

    • profile image

      abhinav vats 6 years ago

      it is very helpful so plz keep it up

    • profile image

      magoo 6 years ago

      that was short and precise, thank you!

    • profile image

      Hasnain 6 years ago

      If any one have any good material regarding c & c++,plz send me at

    • profile image

      Ramisha Rukhsar 6 years ago

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

    • profile image

      monisha 6 years ago

      what is abstract datatype?

    • profile image

      Arun Mavi 6 years ago

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

    • profile image

      priyanka 6 years ago

      Thanks, it helps me a lot

    • Java Programs profile image

      Java Programs 6 years ago from India

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

    • profile image

      ankur 6 years ago

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

    • profile image

      jaswant kumar 6 years ago

      i think four batter c program tools this web site

    • profile image

      anchal 6 years ago

      kuch samajh nah araha

    • profile image

      santhosh kumar 6 years ago

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

      pls help me....

    • profile image

      raj 6 years ago

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

    • profile image

      mekhzam 6 years ago

      this is very nice

    • profile image

      Ajay bidhauliya 6 years ago

      need to few is described

    • profile image

      Ajay PAtil 6 years ago

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

      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 plzzzzzzzzzzz u knw correcr n accurate ans den post otherwise don't post

    • profile image

      kalpana 6 years ago

      so confuse and so boring

    • profile image

      ravi ranjan 6 years ago


    • fahad akhtar profile image

      fahad akhtar 6 years ago from pakistan

      plzzzz give me about the idea of modulus in algorithm

    • profile image

      sree 6 years ago

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

    • profile image

      Md Ali Umar 6 years ago

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




    • profile image

      INSI 6 years ago


    • profile image

      dude 6 years ago

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

    • profile image

      supriya,s.p.jain college 6 years ago

      thank's for deeply information

    • profile image 6 years ago

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

    • profile image

      Nibedita Swain 6 years ago

      What variable? explane pointer variable

    • profile image

      md wakash ahmad 6 years ago

      why uses # in c program

      please reply this topic on that site

    • profile image

      kanchan Pande 6 years ago

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

    • profile image

      Sanket Sathe 6 years ago


    • profile image

      sanjeev kumar 6 years ago

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

    • profile image

      kamaluddin ahmed 6 years ago

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

    • profile image 6 years ago

      what's the mean by recursion?

    • profile image

      aruna devi 6 years ago

      what are data types in c?

    • profile image

      krish 6 years ago

      very fine historical and briefly knowledge of c. good one

    • profile image

      codeguru 6 years ago

      this article is so so not good

    • profile image

      arvnagendrakumar5 6 years ago

      i love c programs

    • profile image

      bk 6 years ago

      Too nice sis it is very koalaveru da

    • profile image

      adil khan 6 years ago

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

    • profile image

      Raj 6 years ago

      am a student of cse but from bio background so plz help me my email id

    • profile image

      mobigujjar 6 years ago

      I m a stdnt of BS(IT)

      plz u help me in this field

      plz snd email address to me

    • profile image

      Vamshi 6 years ago

      Nice site bro..

      It is very use full...

    • profile image

      yasir lovee 6 years 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........

    • profile image

      prince suwalka 6 years ago

      c lang is very mindblowing lang

    • profile image

      cheryl 6 years ago

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

    • profile image

      all bca 6 years ago

      c language is so so so so so so easier dude

    • profile image

      Sunti Lhatdavong 6 years ago

      I like C language

    • profile image

      chitti 6 years ago

      i gave a seminar using this

    • profile image

      chitti 6 years ago

      thnk u bro 4 such a good expl

    • profile image

      chitti 6 years ago

      thnk u

    • profile image

      chitti 6 years ago

      gud expl

    • profile image

      nikhil so.... 6 years ago

      thank u very much ...:)

    • profile image

      jhin_jhin 6 years ago

      i liKe it.

    • profile image

      dinesh 6 years ago

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

    • profile image

      faizkiki family 6 years ago

      thank u

    • profile image

      fasial 6 years ago

      its support very well for my exam

    • profile image

      mohd kashif 6 years ago

      great work

    • profile image

      ravi 6 years ago

      @ sai ram

      which branch r u ??

    • profile image

      sai ram 6 years ago

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

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

    • profile image

      sai ram 6 years ago

      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

    • profile image

      chinni 6 years ago

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

    • profile image

      m kashif 6 years ago

      simple but easy to understand. so execelent

    • profile image

      Ravi 6 years 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.

    • profile image

      srinu 6 years ago

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

    • rajkishor09 profile image

      RAJKISHOR SAHU 6 years ago from Bangalore, Karnataka, INDIA

      @Parvez size of any data type is compiler dependent.

    • profile image

      ruji 6 years ago

      what is c plz tell me ....

    • profile image

      Parvez 6 years ago

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

      plsss reply back!!!

    • profile image

      teja 6 years ago

      what is the use of %u in c language

    • profile image

      Syed Zaheer 6 years ago

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

    • profile image

      vallabhi 6 years ago

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

    • profile image

      Karan 6 years ago


    • profile image

      suyash47 6 years 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,...

    • profile image

      sajan 6 years ago

      i luve studyin c programming. studying

    • profile image

      sajan 6 years ago

      i love c programming its very useful.

    • profile image

      rahul 6 years ago

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

    • profile image

      tamanna 6 years ago

      too difficult and bkkwwaaaaaaaaasss

    • profile image

      twinkle 6 years ago

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


    This website uses cookies

    As a user in the EEA, your approval is needed on a few things. To provide a better website experience, uses cookies (and other similar technologies) and may collect, process, and share personal data. Please choose which areas of our service you consent to our doing so.

    For more information on managing or withdrawing consents and how we handle data, visit our Privacy Policy at: ""

    Show Details
    HubPages Device IDThis is used to identify particular browsers or devices when the access the service, and is used for security reasons.
    LoginThis is necessary to sign in to the HubPages Service.
    Google RecaptchaThis is used to prevent bots and spam. (Privacy Policy)
    AkismetThis is used to detect comment spam. (Privacy Policy)
    HubPages Google AnalyticsThis is used to provide data on traffic to our website, all personally identifyable data is anonymized. (Privacy Policy)
    HubPages Traffic PixelThis is used to collect data on traffic to articles and other pages on our site. Unless you are signed in to a HubPages account, all personally identifiable information is anonymized.
    Amazon Web ServicesThis is a cloud services platform that we used to host our service. (Privacy Policy)
    CloudflareThis is a cloud CDN service that we use to efficiently deliver files required for our service to operate such as javascript, cascading style sheets, images, and videos. (Privacy Policy)
    Google Hosted LibrariesJavascript software libraries such as jQuery are loaded at endpoints on the or domains, for performance and efficiency reasons. (Privacy Policy)
    Google Custom SearchThis is feature allows you to search the site. (Privacy Policy)
    Google MapsSome articles have Google Maps embedded in them. (Privacy Policy)
    Google ChartsThis is used to display charts and graphs on articles and the author center. (Privacy Policy)
    Google AdSense Host APIThis service allows you to sign up for or associate a Google AdSense account with HubPages, so that you can earn money from ads on your articles. No data is shared unless you engage with this feature. (Privacy Policy)
    Google YouTubeSome articles have YouTube videos embedded in them. (Privacy Policy)
    VimeoSome articles have Vimeo videos embedded in them. (Privacy Policy)
    PaypalThis is used for a registered author who enrolls in the HubPages Earnings program and requests to be paid via PayPal. No data is shared with Paypal unless you engage with this feature. (Privacy Policy)
    Facebook LoginYou can use this to streamline signing up for, or signing in to your Hubpages account. No data is shared with Facebook unless you engage with this feature. (Privacy Policy)
    MavenThis supports the Maven widget and search functionality. (Privacy Policy)
    Google AdSenseThis is an ad network. (Privacy Policy)
    Google DoubleClickGoogle provides ad serving technology and runs an ad network. (Privacy Policy)
    Index ExchangeThis is an ad network. (Privacy Policy)
    SovrnThis is an ad network. (Privacy Policy)
    Facebook AdsThis is an ad network. (Privacy Policy)
    Amazon Unified Ad MarketplaceThis is an ad network. (Privacy Policy)
    AppNexusThis is an ad network. (Privacy Policy)
    OpenxThis is an ad network. (Privacy Policy)
    Rubicon ProjectThis is an ad network. (Privacy Policy)
    TripleLiftThis is an ad network. (Privacy Policy)
    Say MediaWe partner with Say Media to deliver ad campaigns on our sites. (Privacy Policy)
    Remarketing PixelsWe may use remarketing pixels from advertising networks such as Google AdWords, Bing Ads, and Facebook in order to advertise the HubPages Service to people that have visited our sites.
    Conversion Tracking PixelsWe may use conversion tracking pixels from advertising networks such as Google AdWords, Bing Ads, and Facebook in order to identify when an advertisement has successfully resulted in the desired action, such as signing up for the HubPages Service or publishing an article on the HubPages Service.
    Author Google AnalyticsThis is used to provide traffic data and reports to the authors of articles on the HubPages Service. (Privacy Policy)
    ComscoreComScore is a media measurement and analytics company providing marketing data and analytics to enterprises, media and advertising agencies, and publishers. Non-consent will result in ComScore only processing obfuscated personal data. (Privacy Policy)
    Amazon Tracking PixelSome articles display amazon products as part of the Amazon Affiliate program, this pixel provides traffic statistics for those products (Privacy Policy)