Hi everyone, I'm working on this code but I get an error. could someone help me how to fix it? I also put 0 after the return but I don't get any answer.
Third, don't mix your C and C++ header files.
#include <cmath> and #include <math.h> is entirely pointless.
Fourth, the return 0 thing has NOTHING to do with the fact that the rest of your program doesn't produce output.
> return c = (a + b) / 2;
This return statement will always prevent the cout line on the next line from being seen.
Fifth, compile with more warnings.
1 2 3 4 5 6 7 8 9 10 11 12 13 14
$ g++ -Wall -Wextra foo.cpp
foo.cpp: In function ‘int main()’:
foo.cpp:17:7: warning: variable ‘N’ set but not used [-Wunused-but-set-variable]
int N;
^
foo.cpp:19:10: warning: variable ‘phi’ set but not used [-Wunused-but-set-variable]
double phi;
^
foo.cpp:20:10: warning: variable ‘Force’ set but not used [-Wunused-but-set-variable]
double Force;
^
foo.cpp:26:10: warning: variable ‘fb’ set but not used [-Wunused-but-set-variable]
double fb;
^
It's for you to decide whether you actually intended to use those variables, or whether they're just useless in this program. Use them, or delete them.