Hi,
I want to write a code that calculate the dy/dx=u (which u is a constant number) by euler method. But there is error in line 51
When I write for example 10 instead of u in line 51 (and delete line 18) and enter 40 for MAX it works and the final answer is near 400 but when I want to change the code in that way that it ask me 10 in line 18 and put to u and calculate it in does not work. why? how can I correct it?
1. Your indentation is not informative. It is hard to see the scopes.
2. You say "there is error". I bet you mean: "compiler returns an error", but you don't tell what the compiler actually says. It is very useful to learn to understand what the compiler tells you.
14:15:44 **** Incremental Build of configuration Debug for project tesy10 ****
Info: Internal Builder is used for build
g++ -O0 -g3 -Wall -c -fmessage-length=0 -o main10.o "..\\main10.cpp"
..\main10.cpp: In function 'double f(double, double*, int)':
..\main10.cpp:58:14: error: 'u' was not declared in this scope
return(u); /* derivative of first equation */
^
..\main10.cpp:59:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
It says u is not declared in this scope at line 51
double f(double x, double y[], int i , double u) /// u is a parameter
{
return(u); /* derivative of first equation */
}
/// then again I noted you are not using parameters x, y, and i what is their need.