When I try to compile the following code in borland it tells me that there is incorrect syntax with the for () loop and that the statement is missing. I don't understand why the syntax is wrong, i have put an initializing statement, then a condition, then the increment increaser... Can anyone suggest what I may have done wrong... Any help greatly appreciated.
note: the program is designed to calculate the time of filling of a tank with varying radi with height by means of trapezoidal integration.
Code:
#include<stdio.h>
#include<math.h>
main()
{
/*declaring variables*/
float i,h,r,p;
float hlevel,llevel;
float D1, D2, D3;
float Qo,Qi,dt,w;
float time;
/*declaring functions*/
/*float time( float r);*/
/*defining variables*/
#define n 500;
#define pi 3.1415926535897932384626433832795;
#define g 9.81;
D1= 6.0;
D2= 3.7;
D3= 2.7;
hlevel= 0.5;
llevel= 5.0;
w=(hlevel-llevel)/n;
/*getting user input for density*/
printf("Welcome to the surge tank simulator program\n");
printf("Please enter the liquid density (kg/m^3):\n");
printf("p=");
scanf("%f", &p);
/*trapezoidal integration using for loop*/
for(i=1;i<n;i++)
{
h= 0.5+(i*w);
Qo= 0.000004*(sqrt((p*g*h)));
Qi= 300;
if(h <= D3 && h >= 0.5)
{
r= 1.5;
}
if(h <= D2 && > D3)
{
r= (0.5)*(5.7-h);
}
if(h <= 5.0 && > D2)
{
r= (3.5/3.22)*(h - 2.78);
}
dt= ((pi*(r*r))/(Qi-Qo))*w ;
time= time + dt;
} /*end for... i.e. i does not equal less than or equal to n*/
printf( "The high level alarm sounds after %f, hours\n", time);
} /*end main*/