having trouble with a question
Write a C++ program that calculates
1/(1 × pow(2,3) + 1/(pow(2, 2) ×pow 3, 3) + 1/(pow(3, 2×pow (4, 3) + ... + 1/(pow(98,2)×pow(99,3 ) + 1/(pow(99)2×pow(100, 3)...
i have two options they are:
option 1:
#include <iostream>
#include <cmath>
using namespace std;
int main ()
{
int a, b, c ;
double total;
a = 0;
b = 1;
c = 0;
total = 0;
for (double a , b ; a < 100 && b<=100; a++ && b++)
{
total = 1 /( pow (a, c) * pow ( b , 3 )+ total );
c = 2;
}
cout<<total<<endl;
system("pause");
return 0;
}
option 2:
#include <iostream>
#include <iomanip>
using namespace std;
int main () {
double sum=0, badSum=0;
for (int i=1; i<100; i++) {
sum+= 1.0/ (1.0 * i * i *(i+1) * (i+1) * (i +1));
badSum+=1.0/( i* i* (i+1) * (i+1) * (i+1));
}
cout << "sum= " << fixed << setprecision(16) << sum <<endl;
cout << "bad sum= "<< badSum << endl;