Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a C code for the following program: The average velocity of water in a rectangular open channel can be calculated using the following Manning's

Write a C code for the following program:

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

The average velocity of water in a rectangular open channel can be calculated using the following Manning's equation. 2/3 n B+2H where U is the average velocity of the water (m/s), 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) 1/3 Develop a program that requests from the user characteristics of the channel and display in table form how the average velocitv 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 coefficient), 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 of lines 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: o Declare a variable of type CHANNEL which will contain channel characteristics o 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 In the function getInput o This function has only a single parameter, a pointer to a value of type CHANNEL o Use the function fgets to initialise the member name (this function will place the complete line typed by the user including spaces as opposed to the scanf function that stops when it encounters a space). For the value of the other members of the structure variable (that are of type double), used the function getPositiveValue from the CylinderVolumeLab5 project to ensure that a positive value is stored in each of these members. Be sure to use the getPostiveValue function from lab 5 and not the version from lab 4 This function DOES NOT return any value o The average velocity of water in a rectangular open channel can be calculated using the following Manning's equation. 2/3 n B+2H where U is the average velocity of the water (m/s), 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) 1/3 Develop a program that requests from the user characteristics of the channel and display in table form how the average velocitv 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 coefficient), 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 of lines 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: o Declare a variable of type CHANNEL which will contain channel characteristics o 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 In the function getInput o This function has only a single parameter, a pointer to a value of type CHANNEL o Use the function fgets to initialise the member name (this function will place the complete line typed by the user including spaces as opposed to the scanf function that stops when it encounters a space). For the value of the other members of the structure variable (that are of type double), used the function getPositiveValue from the CylinderVolumeLab5 project to ensure that a positive value is stored in each of these members. Be sure to use the getPostiveValue function from lab 5 and not the version from lab 4 This function DOES NOT return any value o

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_2

Step: 3

blur-text-image_step3

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

DB2 Universal Database V7.1 Application Development Certification Guide

Authors: Steve Sanyal, David Martineau, Kevin Gashyna, Michael Kyprianou

1st Edition

ISBN: 0130913677, 978-0130913678

More Books

Students also viewed these Databases questions