Please write a C++ program that approximates the value of/4 using the formula /4
ID: 3614535 • Letter: P
Question
Please write a C++ program that approximates the value of/4 using the formula /4 = 1 - 1/3 + 1/5 - 1/7 + 1/9 - .... Stop when the added or subtracted term is less than10-6 (1E -06). Need to use While Loop Please write a C++ program that approximates the value of/4 using the formula /4 = 1 - 1/3 + 1/5 - 1/7 + 1/9 - .... Stop when the added or subtracted term is less than10-6 (1E -06). Need to use While LoopExplanation / Answer
#include #include using namespace std; int main() { int n = 0; int i = 1; double answer = 1; double approximate = 0; while ( abs( answer ) >= .000001 ) { answer = (pow( -1.0, n)) / i; approximate = approximate +answer; n++; i = i + 2; } coutRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.