Ўзбекистон республикаси ахборот технологиялари ва коммуникацияларини


Download 59.11 Kb.
bet5/5
Sana18.06.2023
Hajmi59.11 Kb.
#1598153
1   2   3   4   5
Bog'liq
4-dedlayn

1 – misol: ni ε = 10-4 aniqlikda hisoblang.
#include
#include
using namespace std;
int main()
{
float s = 0, y1 = 0, y2 = 0, x = 0;
int i = 1,k = 0;
const float eps = 1E-4;
cout << "x ni qiymatini kiriting: ";
cin >> x;
y1 = 2*x*i/(i*i);
s+=y1;
y2 = 2*x*(i+1)/(pow(i+1,2));
while(abs(y1-y2)>eps)
{
y1 = y2;
i++;
k++;
s+=y1;
y2 = 2*x*(i+1)/(pow(i+1,2));
}
printf("Natija: %7.4f\nTakrorlanishlar soni: %i\n",s,k+2);
return 0;
}
Natija:
Download 59.11 Kb.

Do'stlaringiz bilan baham:
1   2   3   4   5




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling