why dont i get the output i expect from this insanley simple code?

the ouput is 4287928!!!!
1
2
3
4
5
6
7
8
9
10
11
12
13
  #include <iostream>
#include <cmath>

main()
{
    int square_of_sum,sum_of_squares;
    for(int x = 1;x<11;x++)
        {
            sum_of_squares++;
        }
    std::cout<<sum_of_squares<<"  ";
}
@devonrevenge

You didn't initialize the variables, square_of_sum or sum_of_squares, so they start with a random number.
You should also put a return value (zero) and a return type (int) for function main.
Topic archived. No new replies allowed.