GeeksforGeeks App
Open App
Browser
Continue

# Difference between data type and data structure

Data Type

A data type is the most basic and the most common classification of data. It is this through which the compiler gets to know the form or the type of information that will be used throughout the code. So basically data type is a type of information transmitted between the programmer and the compiler where the programmer informs the compiler about what type of data is to be stored and also tells how much space it requires in the memory. Some basic examples are int, string etc. It is the type of any variable used in the code.

## CPP

 `#include ``using` `namespace` `std;` `void` `main()``{``    ``int` `a;``    ``a = 5;` `    ``float` `b;``    ``b = 5.0;` `    ``char` `c;``    ``c = ``'A'``;` `    ``char` `d[10];``    ``d = "example";``}`

As seen from the theory explained above we come to know that in the above code, the variable ‘a’ is of data type integer which is denoted by int a. So the variable ‘a’ will be used as an integer type variable throughout the process of the code. And, in the same way, the variables ‘b’, ‘c’ and ‘d’ are of type float, character and string respectively. And all these are kinds of data types.

Data Structure

A data structure is a collection of different forms and different types of data that has a set of specific operations that can be performed. It is a collection of data types. It is a way of organizing the items in terms of memory, and also the way of accessing each item through some defined logic. Some examples of data structures are stacks, queues, linked lists, binary tree and many more. Data structures perform some special operations only like insertion, deletion and traversal. For example, you have to store data for many employees where each employee has his name, employee id and a mobile number. So this kind of data requires complex data management, which means it requires data structure comprised of multiple primitive data types. So data structures are one of the most important aspects when implementing coding concepts in real-world applications. Difference between data type and data structure:

My Personal Notes arrow_drop_up