I'm trying to add all the square root answer but why am i getting this output: -858993430

#include <iostream.h>
void main()
{
int input;
int sqrt;
int i, sum, add;
cout << "Please enter your desire number: ";
cin >> input;
for (i=1; i <= input; i++)
{
sqrt = i * i;
add = sqrt;
cout << i << "^2 = " << sqrt<< "\n";
sum += add;
}
cout << "the sum is: " << sum;
}

what could be wrong? hope you could help me with this. thanks!

i got it! hmmm.... i cant use other than void... i'm not a pro yet and i must stick with the way my prof has taught us. though yah it would be nice to experiment from time to time but as now i have to stick with it :(. new ways are hard for me to understand especially when you have tones of assignments regarding it! hahaha!

but anyway, i appreciate it! thank a lot everybody!

so here's my code and glad to have it work... after how many paper scratches for computation.. :(

#include <iostream.h>
void main()
{
int input;
int sqrt;
int i, sum, add;
cout << "Please enter your desire number: ";
cin >> input;
cout << "\n" ;
for (i=1; i <= input; i++)
{
sqrt = i * i;
cout << "\n" << i << "^2 = " << sqrt<< "\n";
sum = sum + sqrt;
}
add = 0;
for (i=0; i <=input; i++)
{
sum = i * i;
add = add + sum;
}
cout << "\nThe sum is: " << add << "\n\n";
}

now my next problem is how to do the sum of powers from 1 to n :(

INGGRIS
How to connect device scanner with visual basic, its analogy I made button scan in vb and typing button scan in press scanner live and walk .. how? Help ...

For Each ctrl As Control In Me.Controls("pnlMainPanel").Controls
If ctrl.GetType Is GetType(System.Windows.Forms.Panel) Then
For Each subCtrl As Control In ctrl.Controls
If subCtrl.GetType Is GetType(System.Windows.Forms.TextBox) Then
MsgBox(subCtrl.Text)
End If
If subCtrl.GetType Is ...