### How to rewrite this part of code using FOR LOOP

Hello, I can't figure out how to rewrite this part of code by for loop?
 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566`` `````` //Project 2 #include #include #include ifstream datain; ofstream dataout; using namespace std; int main() { float FX,X1,X2,X3,FX1,FX2,L,Y,Lambda,I; float X=0,g=9.8; float material[13][3]; string name[13]; int row,col; //finding x1 x2; FX=1-.375*X+.028125*pow(X,2)-.0008789*pow(X,3)+.000012*pow(X,4); if(FX>0) { do { FX=1-.375*X+.028125*pow(X,2)-.0008789*pow(X,3)+.000012*pow(X,4); X1=X-.25; cout<0); } else if(FX<0) { do { FX=1-.375*X+.028125*pow(X,2)-.0008789*pow(X,3)+.000012*pow(X,4); X1=X-0.25; cout<.0010); system ("pause"); }``````

Last edited on
here what I am done so far, but I can't figure out how can "pick " corect value for X..
 ``1234567891011121314151617181920212223242526272829303132333435363738`` `````` //Project 2 #include #include using namespace std; int main() { //variables float start, end, inc, ans,x,y,x1,x2; start=0; end=5; inc=.25; cout<<" x....."<<" y"; for(x=start;x<=end;x=x+inc) { y=1-0.375*x+0.028125*pow(x,2)-0.0008789*pow(x,3)+0.000012*pow(x,4); cout<<"\n"; cout<<" "<
@zed55

The fundamental problem is that you cannot compare floating point numbers directly, so doing so in a loop condition will almost certainly fail. Use integer values in loop conditions, cast them to double inside the loop.