/* MAE 9: Quiz #4, Fall 2005 Due on Wednesday, November 30, Turnin by 10:00 pm Use the program skeleton below (starting with #include ) as the starting point for quiz4. Add the necessary code to the functions prob1() and prob2(), and add the other 2 functions, as described in the text below. You do not need to change anything in main(). In void prob1(void), take a double floating-point number x from the keyboard and compute the function f(x), which is defined by: f(x) = exp(x)-log10(x)+log(x) if x >=4 f(x) = x * sin(x) if -3 < x < 4 f(x) = x*2 + 4*x - sinh(x) if x <= -3. This function should be computed in: double func(double x). In prob1(void), print x and f(x) on the screen. In void prob2(void), take the number of elements k that is less than 16, and the elements of a k-component vector v[] from the keyboard. Print the entered vector v[] on the screen. Pass the vector v[] and k to a double function: double norm(double *v, int k) to compute and return the length of the vector, and the unit vector components. In prob2(void), print the components of the unit vector on the screen. If k>5, let 5 components of the vector appear in one line on the screen. Print also the length of the original vector. */ /* Program skeleton */ #include #include void prob1(void); void prob2(void); double func(double x); double norm(double *v, int k); main() { int menu; printf("There are two functions: prob1() and prob2().\n"); printf("Enter the function number to execute (1 or 2):"); scanf("%d", &menu); /* form a switch to execute one function */ switch(menu) { case 1: prob1(); break; case 2: prob2(); break; default: printf("prob%d() does not exist.\n", menu); } exit(0); } /* Problem 1 */ void prob1(void) { printf("Here is Problem 1:\n"); return; } double func(double x) { } /* Problem 2 */ void prob2(void) { double v[15]; printf("Here is Problem 2:\n"); return; } double norm(double *v, int k) { } ......................... /* Your output should look like: iacs5.ucsd.edu 36: a.out There are two functions: prob1() and prob2(). Enter the function number to execute (1 or 2): 1 Here is Problem 1. Enter a double f-p constant: 1.2 f(1.2) = 1.118e+00 iacs5.ucsd.edu 37: a.out There are two functions: prob1() and prob2(). Enter the function number to execute (1 or 2): 2 Enter the number of elements (<16): 7 Enter 7 double f-p constants -1.2 3.1 -0.5 2.1 7.15 -2.4 0.96 v[] as entered: -1.200e+00 3.100e+00 -5.000e-01 2.100e+00 7.150e+00 -2.400e+00 9.600e-01 normalized v[]: -1.400e-01 3.616e-01 -5.832e-02 2.449e-01 8.339e-01 -2.799e-01 1.120e-01 ||v||=8.574e+00 */