+ 1
what is the difference between variable and datatype
wanted a brief description between variable and dstatypes
4 Answers
+ 6
Variable - something that can change/mutate
Data Type - defines what type of data should be stored within the variable.
Example:
string name = "malcom";
string is the data type in this case and it says " the variable "name" must hold a value of type string otherwise compiler error will be thrown".
name in this case is the variable . But since strings are immutable the value that "name " holds cannot be changed after creation. However for structure types the variable can mutate.
+ 5
variable stores information. datatype lets spesific information to be stored in a variable.
for example:
string name = "Jack";
here string is a datatype and it tells variable called name to store text
+ 1
A variable can vary and defines something, a data type defines what type of data it should be, which is pretty self-explanatory
0
Variable allocates part of tge memory to store value of specific datatype