Incorrect Loop

I am trying to display a polynomial equation using numbers entered by the user. When trying to decipher the negative and positive value of the numbers it keep displaying incorrectly It compiles but I'm missing something. Comments? Also, I need to create a program that can solve a polynomial equation. I keep finding all sorts of formulas, but they use functions and have imaginary numbers and involve guessing, which a computer can not do. Any guidance would be very appreciated! Here is my loop:

while (n == end)
{
cout << nums[n] << "x";
n++;
if (nums[n] > 0)
{
cout << " + ";
}
else
{
nums[n] = abs(nums[n]);
cout << " - ";
}
}
you'll have to give us at least nums[] and end variables so that we know what's going wrong.

Also use code tags it makes it easier to read and allows you to keep your code indented.
Last edited on
nums[] is a vector of numbers that the user has input
closed account (zb0S216C)
What's the definition of end?

Try moving the n++ statement to the end of the loop (after the body of else).

Wazzak
Topic archived. No new replies allowed.