i need help for this program this program can count how many number you have input until the negative number is entered (using only loop) i start the program with do while.. is correct?
this program you entered a positive number end the output you say how many number you have enter The last number he has written is negative and then stops the loop.
"this program you entered a positive number end the output you say how many number you have enter The last number he has written is negative and then stops the loop."
well yes? thats kinda what you asked for, wasnt it?
There is a few problems with the code even821 posted. First problem is that number is uninitialized when used in the loop condition for the first time. Another problem is that amountofnumber will be one bigger than it should be.
One way to fix this is to move cin >> number to the loop condition and test it before testing if the number is not negative. That way you never use number uninitialized and the loop will also stop if the user gives an invalid input or if EOF is reached.
haha, sorry for the sloppy code :O
thanks for correcting me peter, i was in the middle of class while writing it, so i kinda couldnt pay too much attention. sorry again, but atleast the code compiled :P