(2-dimensional array) Write a C program that will compute the flow rate in a set
ID: 3762386 • Letter: #
Question
(2-dimensional array)
Write a C program that will compute the flow rate in a set of pipes using the following formula:
Flow rate is given by q=(PI*d^squared/4)*v.
Where q is the flow rate in ft^cubed/sec, (PI*d^squared/4) is the cross-sectional area of the pipe in ft^squared, d is the diameter in ft, and v is the velocity in ft/sec.
The following 2D array values represent the diameter of different pipes, assume that the units of these values are in feet.
diameter_Pipes [4] [8] = {{1.0, 1.125, 1.25, 1.375, 1.5, 1.625, 1.75, 1.875},
{2.0, 2.125, 2.25, 2.375, 2.5, 2.625, 2.75, 2.875},
{3.0, 3.125, 3.25, 3.375, 3.5, 3.325, 3.75, 3.875},
{4.0, 4.125, 4.25, 4.375, 4.5, 4.625, 4.75, 4.875}};
The program will allow the user to enter the velocity value at which they wish to calculate the flow rate for the given set of pipes. Program will then compute the flow rate and display two tables, one displaying the diameter values and the second one displaying the calculated flow rates.
Explanation / Answer
#include<stdio.h>
int main(){
float diameter_Pipes[4][8] = {{1.0, 1.125, 1.25, 1.375, 1.5, 1.625, 1.75, 1.875},
{2.0, 2.125, 2.25, 2.375, 2.5, 2.625, 2.75, 2.875},
{3.0, 3.125, 3.25, 3.375, 3.5, 3.325, 3.75, 3.875},
{4.0, 4.125, 4.25, 4.375, 4.5, 4.625, 4.75, 4.875}};
float velocity,float_rates[4][8];
float const PI = 22.0/7.0;
for(int i=0;i<4;i++)
{
for(int j=0;j<8;j++)
{
printf("Input a velocity for diameter %f : ",diameter_Pipes[i][j]);
scanf("%f",&velocity);
float_rates[i][j] = (PI*diameter_Pipes[i][j]*diameter_Pipes[i][j]/4.0)*velocity;
}
}
printf(" Diameter Flow Rate ");
for(int i=0;i<4;i++)
for(int j=0;j<8;j++)
printf("%f %f ",diameter_Pipes[i][j],float_rates[i][j]);
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.