week of november 12

matrix addition

Write a function that performs matrix addition on two n by m-sized matrices. The function should have the following prototype:
int* mAdd(int[] m1, int[] m2, int n, int m);
The function should return a pointer to the resulting n x m matrix. To perform matrix addition, simply add element i,j in m1 to element i,j in m2 and store the result in element i,j of m3, the result.

week of november 5

calculator from file

Create a program using the doCalc function you wrote for last week. Your program should prompt the user for a file name containing well-formed expressions, one expression on each line. It should also prompt for an output file name. If the output file does not exist, create it. If it already exists, ask the user whether to overwrite the old file or append to it. The program should then perform the calculations from each line of the input file and write the value of each expression to the output file as appropriate.

week of october 29

calculator

Suppose you have a function prototype as follows:
int doCalc(char* expr);
Assume expr is a pointer to a well-formed null-terminated string containing a mathematical expression where a mathematical expression is as follows:
* A number
* Two expressions separated by one of: *, +, -, or /
Thus, 36+16/2-2 is a valid expression while (12+ 2)/4 is not. In this sample question, assume that calculations are performed left to right, without any consideration for order of operations so the result of the expression above is 24, not the meaning of life, the universe, and everything else (AKA 42). The return value of doCalc is the result of doing the calculations on the expression.

Your task is to write this doCalc function.
You may assume for the purposes of this problem that no intermediate result is outside of the bounds of an int.

[an error occurred while processing the directive]