for-loop (problem)


// Enoizat,
// Let me just "refactor" your source code a bit ^_^

#include <iostream>
using namespace std;

int main()
{
int const whatIsThisValue = 4;
int grandTotal = 0;
std::cout << "\nKey a number: Or key any letter to end" << std::endl;
for(auto userInput = 1 + whatIsThisValue; whatIsThisValue < userInput;)
{
std::cout << "Enter a number>";
std::cin >> userInput;
grandTotal += userInput;
}
std::cout << "Grand total is: " << grandTotal << std::endl;
//--
return 0;
}
// Mr. Enoizat I still can not get for loop to work!
// This line are giving me a error > for(auto userInput = 1 + whatIsThisValue; whatIsThisValue < userInput;)
Nobody would not believe I have been trying for (2) days to get this solve and it not solve yet...
Inside your loop condition, you're checking for userInput but the input is inside the loop.

You're also missing the increment statement at the end.
Please, samtheman, don't duplicate posts:
http://www.cplusplus.com/forum/beginner/235291/
http://www.cplusplus.com/forum/beginner/235025/
http://www.cplusplus.com/forum/beginner/235372/

And please use code tags
http://www.cplusplus.com/articles/jEywvCM9/
http://www.cplusplus.com/articles/z13hAqkS/

It seems you've being struggling with this problem (summing up a bunch of numbers in a loop) since 14/04/2018. Am I wrong? What's the part you find so difficult?

Topic archived. No new replies allowed.