// Sum of Squares and Cubes.cpp : Defines the entry point for the console application.

//

```
#include "stdafx.h"
#include <iostream>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
int n,j;
cout<<"Enter a Number:";
cin>>n;
for(j=1;j<=n;j=j+1)
cout<<j*j<< " ";
cout<< endl;
int a,b,c,sum;
a=n+1;
b=2*n+1;
c=n*a*b;
sum=c/6;
cout<<"the sum is:"<<sum<<endl;
cout<<j*j*j<< " ";
cout<<endl;
int d,e,f,g,h,sum2;
d=n*n;
e=n+1;
f=n+1;
g=e*f;
h=d*g;
sum2=h/4;
cout<< "the sum of cubes is : "<<sum2<<endl;
}
```

the problem is that only part of square calculation is giving the right output and not for the cube.....for further convienence im pasting the actual question....

5. Write a program that adds up the squares and adds up the cubes of integers from 1 to N, where N is entered by the user:

Upper Limit: 5

The sum of Squares is 55

The sum of Cubes is 225

Do this by using just one loop that generates the integers. Of course, if you really needed to calculate these sums you would use the appropriate formulas:

12 + 22 + 32 + ... + n2 = n(n+1)(2n+1)/6

13 + 23 + 33 + ... + n3 = n2(n+1)2/4

Add these formulas to your program and print out their results as well as that of the explicit summations.