+ 1

what is the difference between variable and datatype

wanted a brief description between variable and dstatypes

21st Oct 2016, 6:48 AM
Prathyusha varma
Prathyusha varma - avatar
4 Respostas
+ 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.
21st Oct 2016, 9:17 PM
Ousmane Diaw
+ 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
21st Oct 2016, 1:14 PM
Ilyosjon Kamoldinov
Ilyosjon Kamoldinov - avatar
+ 1
A variable can vary and defines something, a data type defines what type of data it should be, which is pretty self-explanatory
29th Oct 2016, 11:36 PM
Someone McSomeone
Someone McSomeone - avatar
0
Variable allocates part of tge memory to store value of specific datatype
23rd Mar 2021, 9:30 PM
Princewill
Princewill - avatar