Question: #include #include // Define symbolic constant #define TRUE 1 #define FALSE 0 #define NUM_VALUES 20 // Number of time/velocity values to display #define D_IX 0

 #include #include // Define symbolic constant #define TRUE 1 #define FALSE0 #define NUM_VALUES 20 // Number of time/velocity values to display #defineD_IX 0 // Index for elements containing depth values (row 0) #define

V_IX 1 // Index for elements containing volume values (row 0) //

#include #include // Define symbolic constant #define TRUE 1 #define FALSE 0 #define NUM_VALUES 20 // Number of time/velocity values to display #define D_IX 0 // Index for elements containing depth values (row 0) #define V_IX 1 // Index for elements containing volume values (row 0) // Definition of a structure type for user input typedef struct { char orientation; // h for horizontal and v for vertical double radius; // in m double length; // in m } CYLINDER; // Prototypes double getPositiveValue(); char getOrientation(); double computeVolume(CYLINDER, double); /*-------------------------------------------------------------------- Function: main Description: Gets from the user values for the radius and lenght of the cylinder as well as it orientation. Fills an array with depth/volume values and then displays in a table these values. ----------------------------------------------------------------------*/ int main() { // Variable declarations CYLINDER cyl; // structure variable fo cylinder // Note in the following 2D array // points[D_IX] is a 1D array that contains the depth values // points[V_IX] is a 1D array that contains the volume values double points[2][NUM_VALUES]; // NUM_VALUES points of depth/volume // to fill the arrays double depth; // depth of the liquid int ix; // for indexing the columns in the 2D array double inc; // for incrementing the depth

// Get input from user, the cylinder radius and length printf("Please enter the value for the cylinder radius: "); cyl.radius = getPositiveValue(); printf("Please enter the value for the cylinder length: "); cyl.length = getPositiveValue(); cyl.orientation = getOrientation(); // Fill the 2D array with depth/volume values depth = 0; if(cyl.orientation == 'v') inc = cyl.length/(NUM_VALUES-1); else inc = cyl.radius/(NUM_VALUES-1); for(ix = 0; ix 0) Description: Reads a real value from the user, checks that it is strickly positive, and returns the value. ------------------------------------------------------------------------*/ double getPositiveValue() { double value; do { scanf("%lf",&value); if(value Another version of the cylinder problem has been provided in CylinderVolumeLab4.zip (contains a CodeBlocks project). This new program computes the volume of the liquid in a cylinder which can be horizontal or vertical. Again you will be debugging the program. This new version uses a structure to store the data given by the user. It uses a 2D array to store the depth/volume values stored which are then displayed in a table on the console The volume of of a liquid in a hollow vertical cylinder with radius r and length L is related to the depth of the liquid, h, as As seen in previous labs, the volume of a liquid in a hollow horizontal cylinder with radius r and length L is related to the depth of the liquid, h, as V arccos The following table gives a test case (with radius-4.5 m and length 11.45 m for a vertical cylinder) for testing the program. Volume 0.000 0.603 38.33776 1.20576.67553 1.808 115.0133 2.411153.3511 3.013 191.6888 3.616 230.0266 4.218 268.3644 4.821 306.7021 5.424345.0399 6.026 383.3776 6.629421.715-4 7.232460.0532 7.834 | 498.3909 8.437536.7287 9.039575.0665 9.642613.4042 The following table provides a test case (with radius 2.1 m and length- 5.6 m for a horizontal cylinder) that can be used for testing the software (the test cases were generated using Microsoft Excel, note that the Excel file also contains intermediate values to help with debugging) Depth (m) 2rh--h)2rh-a arcos--h)2- Volume 0.000000 0.000000 0.110526|0.672305 0.221053 0.937847 0.331579 1.132558 0.442105 1.288947 0.552632 1.419736 0,663158 1.531498 0.773684 1.628154 0.88421 1.712266 0.994737 1.785607 1.105263 1.849459 .215789 1.904776 1.326316 1.952284 1.436842 1.992541 0.000000 1.337534 1.762165 2.002839 2.136939 2.196855 2.200520 2.159447 2.081755 1.973566 1.839725 1.684223 .510451 1.321370 0.000000 0.099610 0.279465 0.509191 0.777389 1.077168 1.403666 1.753142 2.122559 11.886 2.50935 14.052 2.911287 6.303 3.326378 18.628 3.752823 21.016 4.188959 23.458 0.000 0.558 1.565 2.851 4.353 6.032 7.861 9.818 The following are some features used in this program. A structure is used to store the dimensions of the cylinder that is the radius and length. Two functions were added to check the values entered by the user. for the liquid depth and the other for the liquid's volume. Thus the first row contains all the depth values the data). The depth/volume data points are stored in a 2D array. Each column of the array contains 2 values, one tical when plotting Note the use of symbolic constants to eliminate magic numbers Correct the syntax errors and debug the program to find 3 bugs. Report to your TA for marks; you will need to explain what caused the syntax errors and the bugs

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!