1234567891011121314151617181920
#include <iostream> #include <math.h> using namespace std; int main() { int x; int sum = 0; int sumsq; for (x = 1; x <= 100; x++) { sum += pow(x, 2); } sumsq = pow(sum, 2); cout << (sumsq - sum); return 0; }
123
// sum += pow(x, 2); <- bad sum += x*x; // <- good