What is Data Type and variables in C? Easy explanation with real world analogy.

What is Data Type?

The data type is an entity that specifies, what type of data we are storing in a variable.

There are mainly 2 type of data types in C:

  1. Primitive
  2. Non-primitive
  3. Enumeration (optional)
Let's understand them one by one.

Primitive Data Type

It is the system's pre-defined or pre-declared data structure and can store only one type of value.
Example: Integer, Float, Character.

Non-primitive Data Type

It is the user-defined data structure, which means we are the ones who will choose what and how to store our data in what manner.
Example: Array, Linked list, Stack, Queue, structure, pointer, union, etc.

Enumeration Data Type (optional)

It is also a user-defined data type, but it is reserved for making integral constants in the C language.

What is a Variable?

A Variable is like a container that stores a specific type of data.
You can understand easily by this example:
Have you ever seen a water bottle, it is the same as a variable. It is used to store water in it. The same thing happens with a variable in C, it is used to store the specified data type in it.

Syntax: data_type variable_name;

What is sizeof() function in C?

As understood by its name it is a C function, it gives the size of entity ( variables, datatype) whichever is passed in it.

Syntax: sizeof( entity );
If you want to know more you can refer to the below link, in which I have covered this part in the data structure in great detail. Click Here

Popular posts from this blog

Stop writing this code again & again | Make boilerplate in VS Code for C

How to install C Compiler and make VS Code ready for Getting Started with C

Data Structure: Basic Introduction