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
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 Type | Storage Size | Range of Values Can Be Supported |
---|---|---|
int | 2 bytes | -32,768 to 32,767 |
unsigned int | 2 bytes | 0 to 65,535 |
char | 1 byte | -128 to 127 or 0 to 255 |
unsigned char | 1 byte | 0 to 255 |
signed char | 1 byte | -128 to 127 |
short | 2 bytes | -32,768 to 32,767 |
unsigned short | 2 bytes | 0 to 65,535 |
long | 8 bytes | -9223372036854775808 to 9223372036854775807 |
unsigned long | 8 bytes | 0 to 18446744073709551615 |
long double | 10 bytes | 3.4E-4932 to 1.1E+4932 (19 decimals) |
float | 4 bytes | 1.2E-38 to 3.4E+38 (6 decimal places) |
double | 8 bytes | 2.3E-308 to 1.7E+308 (15 decimal places) |
void | null | ‘/0’ |
** 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.
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:
i.e
1.Array
2.Structure
3.Function
4.Pointer
5.Union
** The more of this we will be discussed in the later of this tutorial.
These are basic arithmetic types and which are used to assign certain discrete integer values throughout the program.
eg:
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;
}
Output:
Day 6
Will learn about Variables and constants in the next tutorial:
Visit to check these related articles
technology
Facebook graphing
Encapsulation protects abstraction.
C#- Programming Guide | Starting Phase Learning(1)
When it comes to security services in Noida, there are several reputable companies that cater to various needs. Let me…
Are you tired of dealing with tooth decay, gum problems, and expensive dental treatments? Look no further! Steel Bite Pro…
In the world of fine jewelry, oval moissanite rings have emerged as a captivating choice for those seeking elegance and…
Noida, located in the state of Uttar Pradesh, is a fast-growing hub of digital marketing agencies in India. Choosing the…
As we move into 2023, the world of motorcycles in India is set to see some exciting changes. Manufacturers are…
The Indian Premier League (IPL) is one of the most popular and exciting cricket tournaments in the world. With the…
Leave a Comment