Could someone help me with pi approximation, Please? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Could someone help me with pi approximation, Please?

Write a program to get an approximation of π with a precision of 10^(-5) using the following formula: π=4.0×(1-1/3+1/5-1/7+⋯+〖(-1)〗^(n-1) ×1/(2n-1)) hints: initialize pi =0 and i=1 the absolute value of the adding item determines the precision you can get when putting more items to pi, thus adding item: 〖(-1)〗^(i-1) 1/(2i-1), then when abs(adding item) >precision, update pi with pi += adding item #include<iostream> using namespace std; int main() { Double pi=0; Int n; abs; i=1; pi=4.0*(1-1/3+1/5-1/7+⋯+〖(-1)〗^(n-1)*1/(2n-1)) What should I do next?

24th Nov 2019, 5:35 PM
Lola
1 Answer
0
Следуя вашей формуле, невозможно рассчитать, даже приблизительно, значение π, код-тому подтверждение https://code.sololearn.com/crM8C1jUhLSv/?ref=app
24th Aug 2022, 9:01 AM
dottxt | off
dottxt | off - avatar