I've just started C++ this week, and I have an assignment where you have to create a console application that asked the user how many numbers they would like to sum together, and then loops that many times, taking in a number and adding it to the sum each time. This is what I have -
The result is it doesn't allow me to enter any numbers except the first one. This is what I get when I run it -Code:int main() { int repeat_amount, sum = 0, entered_number; cout << "Enter the amount of numbers you wish to add together: "; cin >> repeat_amount; for (int number = 0;number == repeat_amount; number ++) { cout << "Enter a number: "; cin >> entered_number; sum = sum + entered_number; } cout << sum; }
Enter the amount of numbers you wish to add:
(then i enter a number and hit enter)
0Press any key to continue...



LinkBack URL
About LinkBacks



