Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Develop a c code for the following: For this question, repeat question 2 from assignment 4, but this time, you will use a number of

image text in transcribedimage text in transcribed Develop a c code for the following:

For this question, repeat question 2 from assignment 4, but this time, you will use a number of functions to separate well the various tasks of the program. Recall the question from assignment 4 The average velocity of water in a rectangular open channel can be calculated using the following Manning's equation. SBIH n B+21 where Uis the average velocity of the water (ms), S is the channel slope n is the roughness coefficient (s/m) B is the width (m) H is the depth of the water (m) Develop a program that requests from the user characteristics of the channel and display in table form how the average vclocity of the water varies with its depth in the channel. Use the following new guidelines to develop your program. Definitions Define a structure type CHANNEL that contains with members for the values for the open channel, that is, members name that holds a string for the name of the channel, n (roughness coefficien), slope (value of S), width (value of B), and maxDepth that holds the maximum water depth possible in the channel. Use a symbolic constant to determine the number oflines to display in the table on the console. Use 25 lines in the table to display. Use other symbolic constants to eliminate magic numbers in your program. o o . In the main function: Declare a variable of type CHANNEL which will contain channel characteristics. Declare either a two dimensional (2D) array or two one dimensional (1D) array which shall contain values of type double. In the case of the 2D array, the first row contains the water depth values and the second row contains average water velocity values. In the case of two 1D arrays, one array contains the water depth values and the other contains average water velocity values Get from the user values to initialize all the members of the structure variable of type CHANNEL by calling the function getInput. Fill the 2D array (or the two 1D arrays) by calling the function fillArray Display on the console the desired output by calling the function displayTable. Thus the main function contains only 3 calls to functions (in addition to declaring variables). Address of the structure variable and arrays are passed to the called functions. o o o o o o In the function getInput: For this question, repeat question 2 from assignment 4, but this time, you will use a number of functions to separate well the various tasks of the program. Recall the question from assignment 4 The average velocity of water in a rectangular open channel can be calculated using the following Manning's equation. SBIH n B+21 where Uis the average velocity of the water (ms), S is the channel slope n is the roughness coefficient (s/m) B is the width (m) H is the depth of the water (m) Develop a program that requests from the user characteristics of the channel and display in table form how the average vclocity of the water varies with its depth in the channel. Use the following new guidelines to develop your program. Definitions Define a structure type CHANNEL that contains with members for the values for the open channel, that is, members name that holds a string for the name of the channel, n (roughness coefficien), slope (value of S), width (value of B), and maxDepth that holds the maximum water depth possible in the channel. Use a symbolic constant to determine the number oflines to display in the table on the console. Use 25 lines in the table to display. Use other symbolic constants to eliminate magic numbers in your program. o o . In the main function: Declare a variable of type CHANNEL which will contain channel characteristics. Declare either a two dimensional (2D) array or two one dimensional (1D) array which shall contain values of type double. In the case of the 2D array, the first row contains the water depth values and the second row contains average water velocity values. In the case of two 1D arrays, one array contains the water depth values and the other contains average water velocity values Get from the user values to initialize all the members of the structure variable of type CHANNEL by calling the function getInput. Fill the 2D array (or the two 1D arrays) by calling the function fillArray Display on the console the desired output by calling the function displayTable. Thus the main function contains only 3 calls to functions (in addition to declaring variables). Address of the structure variable and arrays are passed to the called functions. o o o o o o In the function getInput

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Contemporary Issues In Database Design And Information Systems Development

Authors: Keng Siau

1st Edition

1599042894, 978-1599042893

More Books

Students also viewed these Databases questions

Question

in pm What is 3.7 10-11 m in units of pm? pm

Answered: 1 week ago

Question

How does the concept of hegemony relate to culture?

Answered: 1 week ago