Answer the question
In order to leave comments, you need to log in
Double Loop C++. Mathematical example. How to implement?
One cycle is shorter than the other. How to be here?
y = ((a + 2 * x) / (sqrt(x))) - (pow(sqrt(4 * b), 1 / 3));
a = -18
Variable \ Initial value \(STEP)\Con. value
x = -1 (1) 10
b = 2 (2) 10
Answer the question
In order to leave comments, you need to log in
#include <iostream>
#include <cmath>
using namespace std;
int fb(const int& b)
{
return pow(4 * b, 1 / 3);
}
int fax(const int& a, const int& x)
{
return (a + 2 * x) / pow(x, 1 / 2);
}
int main()
{
const int a = -18;
int resultAX = 0;
int resultB = 0;
for(int x = -1; x <= 10; ++x)
{
resultAX += fax(a, x);
}
for(int b = 2; b <= 10; b += 2)
{
resultB += fb(b);
}
cout << "x = " << resultAX << '\n'
<< "b = " << resultB << '\n'
<< "y = " << resultAX - resultB << endl;
}
OUT:
x = -108
b = 5
y = -113
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question