C syntax problem with if statements
I keep getting this pesky error "project.c", line 427: error: expected a ")" I searched all over and found no opening parentheses so I have no idea what this is coming from. Most likely I just made some stupid formatting error but I've checked out some C references and they seem to be consistent with what I did. I also get this error on several other lines as well as "project.c", line 433: error: expected an expression. Here's my code starting with line 391. Any assistance would be greatly appreciated.
if (flag1==1) { if (flag2==1) { if (flag4==1) { if (flag5==1) { //##################For Loops########################## for(i=0;i<cnt1;i++) { sum1 = sum1 + vel1[i]; averagevel1 = sum1 / cnt1; } for(j=0;j<cnt2;j++) { sum2 = sum2 + vel2[j]; averagevel2 = sum2 / cnt2; } for(k=0;k<cnt4;k++) { sum4 = sum4 + vel4[k]; averagevel4 = sum4 / cnt4; } for(l=0;l<cnt5;l++) { sum5 = sum5 + vel5[l]; averagevel5 = sum5 / cnt5; } //##################################################### frontratio = averagevel1/averagevel4; if (frontratio > steerlimit) { slipratio = averagevel2/averagevel1; if (slipratio > maxslip) { torque = (1 - (slipratio - maxslip))*maxtorque; //******Put in serial_printf statement******* } else if (slipratio > threshhold) { torque = 0; } else torque = 1; } else if(frontratio < 1/steerlimit) { slipratio = averagevel5 / averagevel4; if (slipratio > maxslip) { torque = (1 - (slipratio - maxslip))*maxtorque; //******Put in serial_printf statement******* } else if (slipratio > threshhold) { torque = 0; } else torque = 1; } else { slipratio = (averagevel1 + averagevel4) / (averagevel5 + averagevel2); if (slipratio > maxslip) { torque = (1 - (slipratio - maxslip))*maxtorque; //******Put in serial_printf statement******* } else if (slipratio > threshhold) { torque = 0; } else torque = 1; } }//####### This is for flag5 }//######## This is for flag4 }//######## This is for flag2 }//####### This is for flag1 |
Code:
if (flag1 == 1) { |
Sorry about that :) If you come up with anything let me know, thanks.
|
else if (frontratio < 1 / steerlimit) {
would be easier (remember precedence) else if (frontratio < ( 1 / steerlimit )) { |
All times are GMT -5. The time now is 05:45 PM. |