Hi, i cant figure out whats wrong with my code but i need to see the total sum of the odd integers cubed from number say 1 till x
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
int x;
cout << " enter the value for n: " << endl;
cin >> x;
int i = 1;
int sum = 0;
while (i <= x)
{
if (!(i %2==0))
{
pow(i,3);
sum += i;
}
i++;
}
cout << "The sum of odd integers cubes from 1 " << " to " << x<< "is = "<< sum<< endl;
#include <iostream>
usingnamespace std;
int main()
{
unsigned N;
cout << "Input N: "; cin >> N;
N += N % 2;
cout << "Sum of odd cubes is " << N * N * ( N * N - 2 ) / 8;
}