Data Types in C

What is a data type, and how c language stores different data types to store string, float, etc.,

Last Reviewed and Updated on February 7, 2020
Posted by Parveen(Hoven),
Aptitude Trainer and Software Developer

My C/C++ Videos on Youtube

Here is the complete playlist for video lectures and tutorials for the absolute beginners. The language has been kept simple so that anybody can easily understand them. I have avoided complex jargon in these videos.

What is a Datatype?

Each type of data item has a different nature. A datatype is used to describe that nature. Examples of datatypes are int, float, char, double, etc.,

Storing Integer Numbers

Integer numbers can be stored in either of these types-

  1. char
  2. short
  3. int
  4. long
  5. long long

These different types are meant for storing integral numbers. Why are they so many? The answer is that they have different capacities. Some vessels are small, and some are large. A small cup can store water, but water can also be stored in a water tank. It's about the capacity. If I have to store a small numeric such as 20, then all of the above will be able to store it. But the best fit among them is "char" because it is of just the right capacity. There would be no wastage bytes. The storage would be used optimally.

Each of the types described above has an increasing memory size. They need an increasing allocation from the compiler, just like with vessels, as the capacity increases, the vessel size increases as well. A char occupies just one byte, a short occupies 2, and the other ones occupy even more bytes.

Storing Floating Point Numbers

Floating point numbers can be stored in

  1. float
  2. double

A float can store numbers upto six decimal places, and the double is for the higher precision.

Storing Single Characters of Text

Single characters can be stored in a char type.

char k = 'A' ;

Now you would wonder how is it that the char can be used to store numbers also, and single characters of text? The answer is that as far as the compiler is concerned, single characters of text are ASCII numbers for it. Single characters of text are human readable english alphabets, but internally the compiler stores them as numbers. There is no difference between a single character and a number. A char can handle 256 single characters which include punctuation marks, digits, and some greek characters also.

Strings and Single Characters

A string is a series of characters. A string could contain just one character. It could contain thousands of characters also. A string is always written inside double quotes.


string s = "Hoven Trainings" ;

On the other hand, a character is just a single character that's written inside a single quotes.

Strings, Single Characters and numbers

The following code should clarify it all-


char k = '6'; // it is a character, or ASCII number 54

string s = "6"; // it is a string of one character

int m = 6; // it is a number
A number is never written inside double quotes. It becomes a string in that case and numeric calculations cannot be done.

The sizeof Operator

The sizeof operator can be used to determine the memory allocated to a data type or a variable by your compiler.


USAGE: sizeof(char)

Classroom Training

Classroom training in C/C++ is available at our training institute. Click here for details. You can also register yourself here.

Video Tutorial

We have created a video tutorial that can be downloaded and watched offline on your windows based computer. It is in the form of an exe file. No installation is required, it runs by double clicking the file. Since the exe file is hosted on the Google Drive, it should be very safe because Google itself checks for any virus or malware. The video can be watched offline, no internet is required.

Pricing

This single video will cost you USD $5. When you download the video, you will be able to watch the first few minutes for free, as a sample. The video app will prompt you for payment through PayPal and other payment options. If you want ALL VIDEOS, NOT JUST THIS ONE then go here: Complete Set of C/C++ Video Tutorials The entire set is priced at USD $50.

Screenshots

This is a screenshot of the software that should give you a good idea of the available functionality. Click on the image to see a larger view.screenshot of the video being played in the software

Installation

This software doesn't require any installation. Just download and double-click to run it. It doesn't require administrative priviliges to run. It runs in limited access mode, so should be very safe.

supports windows xp and later Supported Operating Systems

These videos can be run on 32-bit as well as 64-bit versions of the Microsoft Windows Operating Systems. Windows XP and all later OS are supported. If you want to run it on Windows XP and Windows Vista, then you must also have the .NET Framework Version 3.5 installed on your machines. Those users who have Windows 7 and later donot have to worry because these operating systems already have the .NET Framework installed on them.

Download Links

IMPORTANT NOTE: This download contains ONLY ONE video. The video is about the topic of this tutorial.

Want ALL Videos? If you want ALL VIDEOS, NOT JUST THIS ONE then go here: Complete Set of C/C++ Video Tutorials. TIP: If you plan to buy these videos, then it would be more economical to buy the entire set.

DISCLAIMER: Even though every care has been taken in making this software bug-free, but still please take a proper backup of your PC data before you use it. We shall not be responsible for any damages or consequential damages arising out of the use of this software. Please use it solely at your own risk.

Please download the software here.
download the video Data Types in C



Creative Commons License
This Blog Post/Article "Data Types in C" by Parveen (Hoven) is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
Updated on 2020-02-07. Published on: 2015-10-05