Help with syntax!
Hi guys, I did a simple 'for' loop for an ODE and I can't figure out what's wrong with the syntax. Hope someone could help me out here, thanks!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
|
#include <stdio.h>
#include <math.h>
#define step = 0.5
#define max = 10
int main(void)
{
int j;
double v, x, xcopy;
x = 1, v = 0;
printf("t=0 x=1 x'=0\n");
for (j=1; j*step<=max; j++)
{
xcopy = x;
x = x + v*step;
v = v + step*(-16*xcopy);
printf("t=%f x=%f x'=%f\n", j*step, x, v);
}
return 0;
}
|
1 2
|
#define step = 0.5
#define max = 10
|
When using #define, you never put an '=' between your variable name and the number.
Oops, missed that out! Thanks!
Topic archived. No new replies allowed.