Question: The main function of your program must contain an array called sine values of 20 elements of type double: Use a constant called SIZE (set

The main function of your program must contain an array called sine values of 20 elements of type double:

Use a constant called SIZE (set to the value 20) for the size of this array, and throughout the rest of program wherever the array size is needed, obtain it through this constant and not the literal number 20.

The values of the array elements must be set to the sine of their index, e.g. sine values[0] must be sin(0), sine values[1] must be sin(1), etc. Setting these values must be done in a function with the prototype:

void fill_array(double array[]);

The fill array function must be called once at the beginning of the program.

The program must display a menu of choices to the user, accept their selection from the menu and respond to it, then display the menu again, until the user chooses to quit.

The valid menu choices are the numbers 1, 2, 3, and 4. If the user enters an invalid integer, the menu must be redisplayed. The program is only required to work if the menu choice is an integer.

If the user chooses a formula from the menu, they must be prompted for the values a and/or b contained in the formula, and then a table displayed showing the calculated values of the resulting formula:

Get the final values of the formula using the pre-calculated values contained in the sine values array dont call the function sin again in this part of the program.

For the values of a and b, the user many enter numbers with or without a fractional part.

Numbers with fractions must be displayed with 3 places after the decimal point, and columns of numbers must be right-aligned, as shown in the sample run below.

Besides the fill array function which is required, you may use other functions of your own design to organize your program if you like.

Use comments to show the main steps in the program, and to document variable declarations.

A sample run of your program should look like:

Formulas for which you can display values:

1. y = a sin(x)

2. y = sin(x) + b

3. y = a sin(x) + b

4. Quit

Enter the number of your choice: 1

Enter the value of a: 1

x y

-- -----

0 0.000 1 0.841 2 0.909

3 0.141

4 -0.757

5 -0.959

6 -0.279

7 0.657 8 0.989

9 0.412 10 -0.544

11 -1.000

12 -0.537 13 0.420

14 0.991

15 0.650

16 -0.288

17 -0.961

18 -0.751

19 0.150

Formulas for which you can display values:

1. y = a sin(x)

2. y = sin(x) + b

3. y = a sin(x) + b

4. Quit

Enter the number of your choice: 3

Enter the value of a: -1.5 Enter the value of b: 2

x y

-- -----

0 2.000 1 0.738 2 0.636 3 1.788 4 3.135 5 3.438 6 2.419 7 1.015 8 0.516

9 1.382 10 2.816

11 3.500

12 2.805

13 1.370

14 0.514

15 1.025

16 2.432

17 3.442

18 3.126

19 1.775

Formulas for which you can display values:

1. y = a sin(x)

2. y = sin(x) + b

3. y = a sin(x) + b

4. Quit

Enter the number of your choice: 4

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!