Hey I am trying to write a program that will take the sum of the squares and I can't figure out what is wrong with my code. Mathematically, it makes sense but the code makes the number way to large. Unless, I am just tried and can't see its driving me nuts. Here is my code.
cout << "Enter a number greater than 0 (less than 1 to quit:) ";
cin >> number;
if (number > 0)
for(int counter = 1 ; counter <= number; counter++)
sum =sum + pow(counter,2);
cout <<"The sum of the squares from 1 to "<< number<< " is "<< sum<<"."<<endl;
cout<<"Press enter to quit."<<endl;