>>i'm just trying to check my code u all if it's correct
does it do what its supposed to do ? If yes, then its ok. If not then you need to fix it. One problem though is that your program will produce data overflow errors if the value of n is too large.
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
The value of x is uninitialized, and the value of y should start at 1 not 0. It might be better to use a for loop instead of a while loop.
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
(1*n)+(2*n)+(3*n)...(n*n) == (1+2+3+..+n)*n == (n+1)/2*n*n
vijayan121
Posting Virtuoso
1,606 posts since Dec 2006
Reputation Points: 1,159
Solved Threads: 287