Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

Programming I

EXAM #2

For each exercise, a C++ file must be attached in your submission. Note that a C++ file is a file text with
the extension .cpp . In addition, some comments about the author of the program must be included in
each C++ file as shown in the figure below:

1. Build a C ++ program that allows users to enter real values in 2 square Matrices (ask the user for the
size of the Matrices which should be from 2x2 to 4x4). Calculate and publish the Matrix that results
from the multiplication of the 2 matrices entered by the user.
THE PRODUCT OF TWO SQUARE MATRICES
For instance, if we want to do a multiplication like the figure Please, type the size of the square matrices: 2
below, our program should be run with this information
Typing the Matrix A:

A[0][0]: 3
A[0][1]: 5
A[1][0]: -2
A[1][1]: 8

Typing the Matrix B:

B[0][0]: 1
B[0][1]: 6
B[1][0]: 2
B[1][1]: -3

A x B is:

13 3
14 -36
2. Build a C ++ program that allows users to enter real values in a Matrix of n rows and m cols (ask the
user for the sizes which should be for n and m between 2 and 4). In addition, allow users typing real
values in a Vector of size m. Calculate and publish the Vector that results from the multiplication of
the Matrix and the Vector entered by the user.
THE PRODUCT OF A MATRIX AND A VECTOR
For instance, if we want to do a multiplication like the figure
below, our program should be run with this information Please, type a value for n: 3
Please, type a value for m: 3

M V R Typing the Matrix M:

M[0][0]: 3
M[0][1]: 1
M[0][2]: 2
M[1][0]: 0
M[1][1]: 4
M[1][2]: 2
M[2][0]: 2
M[2][1]: 5
M[2][2]: 1

Typing the Vector V:

V[0]: 4
V[1]: 6
V[2]: 2

M x V is:

22 28 40

3. Build a program to find the modes in a Vector of size n of some real values according to the concept
of mode in statistics.

For instance:

So, Three C++ files are expected in your submission until Halloween midnight. DO NOT FORGET TO PUT
COMMENTS ABOUT THE AUTHOR IN YOUR C++ FILES. Good luck!

You might also like