I just started programming in C our first asssignment is writing an alogrithm to compute the volume of water in cubic feet, flowing through a pipe of diameter d in feet, with a velocity of v feet per second, give this fomula
r=d/2
area=pi x r squared
volume = area x v
Below i have gotten written in the C source code, my instructor says to write the algorithm like a person normally does,
So does that mean pseudo code or a flowchart or a structure chart? If it is pseudo code how do i do that, we haven't covered anything about writing in pseudo code.
int main() {
double d;//Variable to store value of diameter variable
double v;//Variable to store value of Velocity
double r, PI, area, volume;
printf("Enter a value for diameter : ");//Prompts the user to enter diameter
scanf("%lf", &d);//Saves the value entered by user to d variable
printf("Enter a value for velocity : ");//Prompts the user to enter velocity
scanf("%lf", &v);//Stores value to variable v
r = d/2.0; // Calculates value of r
PI = 3.14; //Constant PI
area = PI*r*r; //Calculates area and store sin variable named area
volume = area*v; //Calculates volume and stores in variable named volume
printf("Volume of water flow is : %f\n" , volume);//Prints the value of volume variable
system("PAUSE");
return 0;//Exit