// summing.cpp // Bob Myers // // A typical kind of for-loop algorithm -- adding things #include using namespace std; int main() { int value; cout << "Enter an integer: "; cin >> value; int sum = 0; // initialize an accumulator variable int i; for (i = 1; i <= value; i++) { if (i % 5 == 0) // if the index is divisible by 5 sum = sum + i; // add it to the accumulator } cout << "In the range 1 through " << value << ",\n\tthe sum of the numbers that are divisible by 5 = " << sum << '\n'; return 0; }