int main() {
double sum = 0.0;
for (int n = 1; n <= 20; ++n) {
sum += 3 / pow((2 * n + 1), 3);
}
std::cout << "The sum of the series is: " << sum << std::endl;
return 0;
}
Natija:__b)'>Natija:
b)
#include
#include
int main() {
double product = 1.0; // Initialize the product to 1
for (int R = 1; R <= 16; ++R) {
double sum = 0.0; // Initialize the sum for this value of R
for (int i = 1; i <= 6; ++i) {
sum += (R + 3) / (pow(R, 3) + 3*R + pow(i, 3));
}
product *= sum; // Multiply the sum into the product
}
std::cout << "The product of the series is: " << product << std::endl;
return 0;
}
Natija:
2-misol.
1-usul.
#include
#include
#include
// Function to find the root of
double f(double x) {
return x - sin(x) - 0.5;
}
int main() {
const double epsilon = 0.0001;
double a = 0;
double b = M_PI / 2;
double c = a;
while ((b - a) / 2 > epsilon) {
c = (a + b) / 2;
if (f(c) == 0) {
break;
} else if (f(a) * f(c) < 0) {
b = c;
} else {
a = c;
}
}
std::cout.precision(5);
std::cout << "The root of x - sin(x) - 0.5 = 0 is approximately: " << std::fixed << c << std::endl;
return 0;
}
Natija:
2-usul.
#include
#include
using namespace std;
double F(double x) {
return x-sin(x)-0.5;
}
double F1(double x) {
return 1-cos(x);
}
double F2(double x) {
return sin(x);
}
int main() {
double a, b, x1, x2, eps;
cout << "a, b = ";
cin >> a >> b;
cout << "aniqlikni kiriting: ";
cin >> eps;
if (F1(a) * F2(a) > 0) {
x1 = a;
}
else {
goto label2;
}
label1:
x2 = x1 - F(x1) * (b - x1) / (F(b) - F(x1));
if (abs(x2 - x1) > eps) {
x1 = x2;
goto label1;
}
else {
goto label3;
}
label2:
if (F1(a) * F2(a) < 0) {
x1 = b;
}
label4:
x2 = x1 - F(x1) * (x1 - a) / (F(x1) - F(a));
if (abs(x2 - x1) > eps) {
x1 = x2;
goto label4;
}
label3:
cout << "tenglama yechimi = " << x1 << std::endl;
}
Natija: