Announcements
• Assignment 3
• Exam 1
– Graded
– Back in recitations on Friday
– Statistics on Thursday (hopefully)
• Read Chapters 11,12, 13 and 22
• Topics for today
– Matrices
– Random numbers
– Strings (time permitting)

This
** preview**
has intentionally

**sections.**

*blurred***to view the full version.**

*Sign up*
Review: 2D Arrays
• Used for tables and matrices
• Declaration similar to one dimensional arrays
• Need to specify both the number of rows and columns
during allocation
• For example:
int myMatrix [10] [10];
double energyTable [5] [6];
char conversionTable [26] [26];

Matrix operations
• C does not have a primitive matrix data type
It’s treated as a 2 D array
– It s treated as a 2
‐
D array
–
Common matrix operations must be
programmed!
• Matrix transpose, inversion, addition, multiplication,
etc.
– C is not MATLAB
– More on matrix operations later
3

This
** preview**
has intentionally

**sections.**

*blurred***to view the full version.**

*Sign up*
What is a Matrix?
• A matrix is a set of elements, organized into rows
and columns
A is a 2 X 2
matrix
2
columns
⎤
⎡
01
00
a
a
⎥
⎦
⎢
⎣
11
10
a
a
2
rows