C Programming: Computing mean effective pressure

136 views Asked by At

So I'm very new to C programming and I'm being asked to write a programming to compute the mean effective pressure of an internal combustion engine's cylinder.

I'm given:

MEP = (66,000 * HP) / (L * A * RPM)

A = (pi * D^2) / 4 (cross sectional area of the cylinder

D = 3.5in. (Cylinder diameter)

L = 0.417ft (cylinder stroke)

RPM = 5000

HP = 110

I'm supposed to output the Bore (in), Stroke (ft), and the MEP (psi).

This seems like a relatively easy programming, but I just need a few walkthroughs to get me to the finish line. I'm using LCC-Win for testing. That is what I have so far:

int main()
{
float A, MEP, D, A, L, RPM, HP; //declaring all variables
D = 3.5;
L = .417;
RPM = 5000;
HP = 110;
MEP = (66000*HP)/(L*A*RPM);
double compute_area(double diameter);
const double pi = 3.14159265;
return (pi * diameter * diameter) / 4;
}
1

There are 1 answers

0
Amit Sharma On

You can try this:

#define pi  3.14159265;    //macro to define value of pi

//function compute_area is defined here
double compute_area(double diameter){   
   return (pi * diameter * diameter) / 4;     
}

int main(){
  double A, MEP, D, L, RPM, HP; //declaring all variables
  D = 3.5;
  L = .417;
  RPM = 5000;
  HP = 110;

  A=compute_area(D);  // calling the function compute_area 

  MEP = (66000*HP)/(L*A*RPM); // calculating the MEP as per your formula
  printf("MEP %f", MEP);   //printing the MEP result
  return 0;
}