int main()
{
int sum = 0, value = 0;
while (std::cin >> value)
sum += value;
std::cout << "Sum is: " << sum << std::endl;
return 0;
}
So this code takes values from the user and adds them. I don't understand what makes it reach end of file. I tested it multiple times and found that when I use larger numbers (9999999999) it ends faster, but when I put in just 1s it never ends.
Aucun commentaire:
Enregistrer un commentaire