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.
inthas a maximum possible value? And if you exceed it, you get a negative result. Its because anintis 32 bits or 64 bits depending upon your PC architecture and represents a range of values from negative to positive using two's complement representation. Google search forintoverflow.