Data types in c

C Tutorial -3: Data Types Available In C

Spread the love

In this C Tutorial, we will learn about the different data types available in C Programming.

To say in easy language Data types are the different types of memory space where you can store the value. Each of the available space has some defined location and fixed memory which can be accessed while compilation/execution of the program.
let’s take an example:

So a man has To store a value in C Language, we have different kinds of data types available. Suppose George has an aquarium, a fruit basket, and a pencil box in his house. What is the purpose of each? So each is being designed and developed to keep certain things in it. Right?As an aquarium is there to keep the fishes, fruit basket to keep fruits, a pencil box to store the pens.
So we don’t store the pen in the aquarium, and fish in the fruit box and fruit in the pencil box.
Though we can force them to store the value in any of the data types. But it can throw an exception of the out of its range which we will discuss in the later of this tutorial. As in the example, we can force fruits in the aquarium but if we force the fish in pencil box it will die (i.e exception thrown).

We have two types of data types available in C :
1.Basic Data Types
2.Derived Data Types
3.Enumerated Data Types

1.Basic Data Types :

So let’s see the different types of basic data types available in the C Language
We can categorize them into different types i.e
1.Arithmetic data type:
2.Void data type
3.Float data type

Data TypeStorage SizeRange of Values Can Be Supported
int2 bytes-32,768 to 32,767
unsigned int2 bytes0 to 65,535
char1 byte-128 to 127 or 0 to 255
unsigned char1 byte0 to 255
signed char1 byte-128 to 127
short2 bytes-32,768 to 32,767
unsigned short2 bytes0 to 65,535
long8 bytes-9223372036854775808 to 9223372036854775807
unsigned long8 bytes0 to 18446744073709551615
long double10 bytes3.4E-4932 to 1.1E+4932 (19 decimals)
float4 bytes1.2E-38 to 3.4E+38 (6 decimal places)
double8 bytes2.3E-308 to 1.7E+308 (15 decimal places)

** Float, double, long double is the decimal handlers in C language and also called floating types.
Whereas the void is an empty data type which is used to return null type values for any function, the more of this will be discussed later in the tutorial.

2.Derived Data Types

Derived data types are those which are built from basic data type. Since its being derived from basic, so the name is being given as derived data types. This includes different types of it:

** The more of this we will be discussed in the later of this tutorial.

3.Enumerated Data Types:

These are basic arithmetic types and which are used to assign certain discrete integer values throughout the program.
enum <Variable name> {const1, const2, …, constN};

enum week {Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday};

void main()
    enum week chk;
    chk= Friday;
    printf("Day %d",chk+1);
    return 0;

Day 6

Will learn about Variables and constants in the next tutorial:
Visit to check these related articles
Facebook graphing
Encapsulation protects abstraction.
C#- Programming Guide | Starting Phase Learning(1)

Leave a Reply

Your email address will not be published. Required fields are marked *