when I compiling this program it gives me this error
In function 'double inflexion(double*)':
27:1: warning: control reaches end of non-void function [-Wreturn-type]
In function 'int ninflexion(double*)':
37:1: warning: control reaches end of non-void function [-Wreturn-type]
In function 'int main(int, char**)':
69:15: warning: iteration 49u invokes undefined behavior [-Waggressive-loop-optimizations]
68:3: note: containing loop
60:39: warning: iteration 49u invokes undefined behavior [-Waggressive-loop-optimizations]
57:4: note: containing loop
and I don't know how to solve it please someone who can find me where is the problem .
a typed function must return a value.
return 3; //this does not happen if 1 does not equal 2.
///nothing is returned: the return was skipped.
//control (the place in the program where it was executing)
//has reached the end (here) of a non void function (its type int) without return.
the infinity (?) loops over i appear to go out of range in the array bounds. This is undefined.
you also take the undefined index via uninitialized variables.
You declared arrays t, xv and yv with one too few elements for the loops that initialise them:
1 2 3
These should be declared with length n, not n-1.
Your compiler didn't pick it up, but the following two lines are (currently) illegal in standard c++ because the array size isn't known at run time:
As @FurryGuy says, please use code tags so that it preserves indentation and we can read your code easily. It would also be useful to state what your code is supposed to do. As far as I can tell it's working out the parametric coordinates of some space curve - but who knows.
thank you, my dear friend.
with this c++ code, I want to simulate a bow-tie filter exactly the filter thickness at each angle theta of the ray coming from the source [computed tomography].
This also runs and produces some output to file.
I've made some changes to make it clear (to me at least) wtf goes on with constants vs variables but this does not mean the program does what it you meant it to do.
The journal(s) seem to be tackling a more complex problem, even involving Monte Carlo methods. maybe that's why you included time/math/rand but didn't use them?
You could make a lot of use of ordinary coding conventions with meaningful variable names and adopting the principles of self-documenting code along with selective but effective commenting. Single letter variable names, to put it bluntly, is bad practice and essentially crap.
The constant LIMIT could possibly introduce an off-by-one-error with what I have done? I have not checked.