In: Computer Science
Name the data type,value type and array size / name of the followings.
1) 20.4
2) a=5
3) [2 3 8]
4) ' 7 '
5) ' abc'
6) pi
7) b=true
8) 20+2i
9) [ 'a' 'b' 'c' ]
10) [ 'a' ; 'b' ]
11) [1 2 ;4 5;7 8]
12) [20,21,22,23]
13) c= [a;b]
14) c= [b:a]
15) d=[b:a ; b:a]
16) magic(3)
17 uint8(20)
18) int8(d)
1) 20.4 - It simply defines a Floating Point value.
2) a=5- It declares an integer value as 5 so that it can be used further for another calculations like shown below
3) [2 3 8] It simply creates a 1-d array having 1 row and 3 column i.e 1x3 Array with values- 2,3,8
4) ' 7 ' - Character
Since now it is written in between single quotes now it is not an integer now it has been defined as a character, That's why if we add directly 7+2 we get 7 but when we add '7' + '2' it adds ASCII values of character 7 and 2 i.e 55 ad 50 and gives us 105
5) ' abc'- Chacter Array with 3 elements, Basically charcter array is nothing but just a sequence of characters
6) pi - It is a function which gives a long floating point number which gives a nearest value of π.
7) b=true- It is used for boolean values or logical value,Where True gives logical value 1 and false gives value 0.
8) 20+2i- Complex Number
9) [ 'a' 'b' 'c' ]- It simply creates an array of characters.
10) [ 'a' ; 'b' ]- Now Here since we placed ; between two characters it will create them as two rows hence it created 2x1 array.
11) [1 2 ;4 5;7 8]- It Creates a 2D Array with 3 rows and 2 columns, in which elements of each row are entered one by one separated by semicolon ";".
12) [20,21,22,23]- It simply creates a 1-d array having 1 row and 3 column i.e 1x3 Array with values- 20,22,22,23
13) c= [a;b]- Now if a=2 and b=5, this instruction will create 2x1 array
14) c= [b:a]- Same here it will just create array with b in first row and a in second one.
15) d=[b:a ; b:a]- It gives a 2x0 empty double matrix.
16) magic(3)- Magic command creates a magic square array of size which is passed, in which sum of elements in a row or column or diagonally is same
So for magic(3) it creates a magic square array of size is (3,3)
Row-wise row 8+1+6=15 Column Wise 8+3+4=15 Diagonal 8+5+2=15
3+5+7=15 1+5+9=15 6+5+4=15
4+9+2=15 6+7+2=15
17 uint8(20)- It converts integer to 8 bit unsigned integer.
18) int8(d)- It gives Integer to 8 bit signed integer.