Thursday, 28 June 2012

c++ program that calculate the sum of following series:

11+22+33+44….n terms

#include<iostream.h>

int main()
{
int i,n,j,sum=0,squ=0;

cout<<"Enter any number : ";
    cin>>n;


for(i=1;i<=n;i++)
{
    for(j=1;j<=i;j++)
    squ=j*j;

sum+=squ;
}
cout<<sum;

}