// FILE: Sum_Int.cpp // FINDS AND PRINTS THE SUM OF ALL INTEGERS FROM 1 TO n #include int main () { // Local data ... int n; // last integer to be added to sum int sum; // sum of all integers from 1 to n // Read the last integer. cout << "Enter the last integer in the sum: "; cin >> n; // Find the sum of all the integers from 1 to n inclusive. sum = 0; for (int i = 1; i <= n; i++) sum += i; // Print the sum. cout << "The sum is " << sum << "." << endl; return 0; }