This is the solution to Quiz 2: Problems - Programming history, MATLAB variables.

The following figure illustrates the grade distribution for this quiz.

1. (A) What is the closest programming language to machine code (i.e., binary code)?
Assembly
(B) Does it need interpretation in order to become machine-comprehensible?
Yes. An Assembler interprets the program for the machine.

2. (A) Name the oldest high-level programming language that is still in active daily usage.
Fortran
(B) Approximately how many decades is it old? ($\pm15$ years is accetasble answer. the decade it was created is also an acceptable answer)
in 1950s

3. (A) Name a second-generation programming language.
Assembly
(B) Which language-generation are Fortran, C, C++, MATLAB?
third, third, third, fourth

4. In what decades C, C++, and MATLAB were created, respectively?
1970s, 1980s, 1980s

5. Name an ancestor programming language of C.
B

6. Name a programming language ancestor of C++.
C, Simula

7. Name a programming language ancestor of MATLAB.
Fortran

8. Initialized a cell array variable C of size $2\times2$, then fill its elements like the following figure.

>> C = cell(2,2)
>> C{1,1} = [1,3,-7;2,0,6;0,5,1];
>> C{1,2} = 'This is a text string.';
>> C{2,1} = [];
>> C{2,2} = [3+4i,-5;-10i,3-4i];

>> C
C =
[3x3 double]    'This is a text string.'
[]                [2x2 double]
>> C{1,1}
ans =
1     3    -7
2     0     6
0     5     1
>> C{2,2}
ans =
3.0000 + 4.0000i  -5.0000 + 0.0000i
0.0000 -10.0000i   3.0000 - 4.0000i


9. Now, if you type C{2} on the MATLAB command line, what do you get? Why do get this value?
You will get the value for the cell element $(2,1)$. This is happens, because as we discussed in class, MATLAB is column-wise language.

10. Does MATLAB follow column-wise data storage, or row-wise? Explain what it means? Why does it follow this storage method? (if you recall, we discussed this in class)
MATLAB stores data in a column-major (columnwise) numbering scheme, which is how Fortran stores matrices. MATLAB uses this convention because it was originally written in Fortran. MATLAB internally stores data elements from the first column first, then data elements from the second column second, and so on, through the last column.

11. How many bytes is a MATLAB integer of type int64? (if you recall, we discussed this in class)
8 bytes.

12. What would happen if you tried to covert a huge integer number that requires MATLAB int64 data type to the MATLAB int32 data type? (if you recall, we discussed this in class)
The huge number is converted to the maximum number that can be represented by int32 data type.
>> intmax('int32')
ans =
2147483647
>> intmax('int64')
ans =
9223372036854775807
>> int32(intmax('int64'))
ans =
2147483647


This is a language-specific rule. In other programming languages, the number may be converted to infinity, if it is bigger than the maximum number that can be represented by the requested integer type.