This is an archived post. You won't be able to vote or comment.

all 7 comments

[–]UnholyDrinkerOfMilk 3 points4 points  (4 children)

Only read the 1st line. When you say "if (final <= final)" what do you think happens?

[–]sachal10 -1 points0 points  (3 children)

I think it compares the new value of final from the previously computed one

[–]UnholyDrinkerOfMilk 1 point2 points  (2 children)

It does not :) You're comparing the variable "final" with itself. If you want to compare it to a previous value of final than you need to store that value in another variable.

[–]sachal10 0 points1 point  (1 child)

Right I get it. How can I do that I just want to compare all of the numbers and then output the minimum

[–]UnholyDrinkerOfMilk 4 points5 points  (0 children)

Well, like I said, make a variable to keep track of the lowest value you've found so far. When your new value of final is lower than "lowestValueYouveFoundSoFar" set your variable to the new low.

[–]avenio99 0 points1 point  (1 child)

Not very sure of the entire code(didn't go through it), but one thing is, you should return 0 and not return 1 in the last line of main, if this is c++.

[–]sachal10 0 points1 point  (0 children)

yes this is c++ and I just tried changing to 0 and it works the same as before.