0

Can you tell what is the purpose of a data type?

30th Aug 2020, 12:37 PM
Paul Stephen
Paul Stephen - avatar
2 odpowiedzi
+ 3
data type tells the compiler what type of data must be store in a variable. Now, what is a variable? A variable is a container. Let's take an example. At home, you've a specific box container for storing only rice. Here, rice is the data type of that specific box container. [So clearly anyone who comes to your would know what to put in that box container (that is rice) .] Same is the case here, int val; int is the data type so the compiler knows that val must only accept integers and no other types. (sorry for the long answer)
30th Aug 2020, 1:42 PM
RKK
RKK - avatar
0
each primitive data type take different numbers of bytes in memory. It is optimised way how to use memory space. simple data type are better for speed of process. data types is good for control if program is realy what programmer want to do complex data types are necessary for OOP
30th Aug 2020, 7:37 PM
zemiak