Question: I have the following code for the following question .How Can I fix my code ? #include #include using namespace std; // Prototype for the
I have the following code for the following question .How Can I fix my code ?
#include
#include
using namespace std;
// Prototype for the functions
float drag(float,float);
float thrust(float);
float grav(float);
int main (void) {
float h[9001],v[9001],mf[9001];
float mo=500,cd=0.15,s=15,T=30000;
float dt=0.05,hmax=0,vmax=0;
float qmax,htmax,vtmax,qtmax,tmax;
float c;
int k,mfn=-1;
cout
cin >> c;
h[0]=0;
v[0]=0;
mf[0]=0;
for(k=0;k
h[k+1] = h[k]+dt*v[k];
if (mf[k]>0){
v[k+1] = v[k]+dt*(((thrust(mf[k]))-drag(h[k],v[k]))/(mo+mf[k]-grav(h[k])));
}
else {
v[k+1] = 0;
mf[k+1] = 0;
}
}
for(k=0;k
if (h[k] > h[k-1]) {
hmax = h[k];
tmax = k*dt;
}
if (v[k] > v[k-1]) {
vmax = v[k];
vtmax = k*dt;
}
}
for(k=0;k
if (h[k] > h[k-1]) {
hmax = h[k];
qtmax = dt*k;
qmax = qtmax * (abs(drag(h[k],v[k])))/(cd*s);
}
}
// Displaying the Calculation
cout
cout
cout
float data;
cout
for(k=0;k
cin >> data;
if (hmax - h[k]
cout
cout
cout
cout
cout
}
}
return 0;
}
// Writing down the functions
float drag(float a,float b) {
float D = (0.15*15/2) * 1.23 * exp(-a/8500) * b * abs(b);
return D;
}
float thrust(float c) {
float th = -c/(c - 9.81);
return th;
}
float grav(float d) {
float G = (3.99*pow(10,14))/((d+6.38*pow(10,16))*(d+6.38*pow(10,16)));
return G;
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
