// // Pgm2_5c.cpp // // For loop to sum up n integers // #include main() { int i; int nobs; int sum=0; cout << "Enter the number in summation: "; cin >> nobs; cout << "There are " << nobs << " terms in the sum!\n\n"; for( i=0; i<=nobs; i++) { sum += i; cout << "\tCurrent Sum is: " << sum << endl; } cout << "\nSum = " << sum << endl; cout << "n(n+1)/2 = " << nobs*(nobs+1)/2 << endl; return 0; }