The output I got was "Sum of numbers is 55." and I was wondering how it calculated that. If I recall correctly, the sum += num is basically sum = sum + num but I don't see how it got 55.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
#include <iostream>
#include <string>
usingnamespace std;
int main()
{
int sum = 0, num;
for (num = 1; num <= 10; num++)
{
sum += num;
}
cout << "Sum of numbers is " << sum << endl;
return 0;
}