+ 1
What is data types?
8 Antworten
+ 3
It is the type of the variable or constant you use
And it very important because before using any variable you should declare it first and to do that you need to specify its type first and there is six of them
Int: for integer number and it is number without decimal point like -15, -6 , 4 , 5 , 1
Double: for number with two numbers after the decimal point lime 10.13, -45.67, 6.00, 1.00
Float: for the real full number with all the numbers after the decimal point ( a large version of double)
Those three are just to declare data that are numbers
Now to the other three
String: is the data that are a sequence if character like a phrase or a word ( can include anything from numbers symbol and letters ) and it is always put inside " " for example: "this a chain of character"
Char: is the data that are made of one letter or symbol and there is a limited number of them and they should be put between ' ' to be a char for example: 'c', '1' ,
Bool: this type only define the data that can only take two value true or false ( sometimes we use 1 instead of true and 0 instead of false)
The type of data could effect totally the result of the program for example the variable 13.89729 we be treated as 13 if its type is int and 13.89 if it is double and 13.89729 if its float
But in the other hand int uses less bite which means less space in the memory which means faster than double or float
So you should chose depending on what you want
Also for example the number 1
If it is writing this way :1 its type is int
If it is writhing this way: '1' its type is char
Also for example 234
If it is writing this way : 234 its type is int
And if it is this way : "233" its type is string
+ 3
@Raizel TheNoblesse
Other way round😉
double is a more precise float, not a float is a more precise double.
Great answer!
+ 2
Data type is a classification of various types of data . such as integer, float
+ 2
Thank you
And that is true :3 you can it that way
+ 1
wrong dude....every variable is a name to piece of memory that you can work with it...so would be confuse to do certain action with variables if all data types are mixed...not needing to use them...so data type its what information you will store on the variable that you declare...if the DATA TYPE is the type int you will work with whole numbers...so you can only store whole numbers in that variable because his data type its to store whole numbers....hope that this helps ;-)
+ 1
wrong dude....every variable is a name to piece of memory that you can work with it...so would be confuse to do certain action with variables if all data types are mixed...not needing to use them...so data type its what information you will store on the variable that you declare...if the DATA TYPE is the type int you will work with whole numbers...so you can only store whole numbers in that variable because his data type its to store whole numbers....hope that this helps ;-)
0
tankx for answering
0
thanks