/* * Question 1 * * Write a program called submean.cc that: * * 1. Reads in from the user a sequence of 10 floats and puts them in an array * 2. Computes and displays the mean value of the sequence * 3. Subtracts from each element of the array the computed mean * 4. Displays the new array * 5. Computes and displays the mean value of the new sequence * * For example: * * Enter the 10 numbers separated by spaces: * 0 1 2 3 4 5 6 7 8 9 * The mean value is 4.5 * The new array is: * -4.5 -3.5 -2.5 -1.5 -0.5 0.5 1.5 2.5 3.5 4.5 * The new mean value is 0 */ /* * Question 2 * * Write a program called transpose.cc that: * * 1. Reads in a 3 x 3 matrix A * 2. Calculates and prints out the tranpose of the matrix A * * Note: The transpose AT of a matrix A is formed by making the rows of A the * the columns of AT. * * For example: * Enter row 0 * 1 2 3 * Enter row 1 * 4 5 6 * Enter row 2 * 7 8 9 * Transpose: * 1 4 7 * 2 5 8 * 3 6 9 */ /* * Question 3 * * The temperature at point x in an 80cm copper bar at time t is given by the * formula (where ^ means "to the power of"): * * u(x, t) = 1.25 sin (pi x / 80) e^(-0.001785 t) * * 1. Write a program that asks the user to enter values for x and t and calls * a function u that computes the corresponding temperature * 2. Have the function u return the computed temperature to the caller which * prints it out * 3. Modify the program so that it repeatedly prompts for values for x and t * and exits only when both values are negative * * Note: sin and exp functions are available from the cmath library and pi can * be assumed to be 3.14. * * For example: * * Enter the position: * 5 * Enter the time: * 5 * Temperature: 0.241575 degrees * Enter the position: * 8 * Enter the time: * 20 * Temperature: 0.372542 degrees * Enter the position: * -1 * Enter the time: * -1 */