# Mid-term exam in 4/2014

```ECE 190/120: Introduction to computing systems
Mid-term Exam 2013-2014
April 2014
Name:
• Time: 90 min.
• This is an exam – computer base test
• Absolutely no interaction between students is allowed
• Show all of your work with the compiler Borland C++ ver 5.0x
• Be sure to clearly indicate any assumptions that you make
• Don’t panic, and good luck!
• Save each program after having done for checking points
Problem 1 (30 points):
Write a program with the function to compute the following summation:
S=𝑥−
𝑥3
3!
+
𝑥5
5!
− ⋯+
𝑥𝑛
𝑛!
Input: x: real value, and absolute error eps: real value, 0 &lt; eps &lt; 0.1
Known: eps is approximate to
𝑥𝑛
𝑛!
, means eps ≤
𝑥𝑛
𝑛!
Problem 2 (30 points):
Enter a list of values, means a vector of values. Sort this list in descending order and
then print out the greatest and least value.
Problem 3 (40 Points):
Known the Haar transform yn of an n-input function xn is
where: - Hn is the Haar transform matrix with n = 4 as the following:
- xn is the data vector input, for example: x4 = [1, 2, 3, 4]
- yn is the output, computed as the following with n = 4:
Write a program with functions appropriately to enter the data vector x4, compute and
print out the output vector y4 with the Haar transform matrix above.
Notice: the function:
double sqrt (double a);
can be used to get the square root of the value a; its prototype is in the file of math.h