Here's the problem.. Write a program that will add up all the 10 consecutive integers using for statement. Example: 1+2+3+4+5+6+7+8 +9+10=55..
output program will be: sum=55.
can't figure it out...i'm just a newbie in c++.
output program will be: sum=55.
can't figure it out...i'm just a newbie in c++.
Code:
#include <iostream.h>
main()
{
int x, sum;
for(x=1;x<=10;x++)
{
sum=x+x;
}
cout<<"sum="<<sum;
cout<<"\n";
return 0;
}
Comment