Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Programming in c, I've written a program to compute the digits of pi. I can't figure out how to print the result every 10,000 iterations.

image text in transcribedProgramming in c, I've written a program to compute the digits of pi. I can't figure out how to print the result every 10,000 iterations. At the moment it prints every single iteration. Any help is appreciated!

#include #include #define EPOCH 10000 //EPOCH defined as a macro int main() int iteration; //int declaration of user input printf("How many iterations of 10,000 would you like: "); //prompt scanf("d", Siteration); //store user input in variable to be used in Loop int total = iteration - EPOCH; //converts the iterations into EPOCH double pi = 0.; //pi set to for alternating signs for(int i=1;ic total;i++) { //for loop to execute for a given number of EPOCHS if (i42 = ) { //if statement to mimick the alternating signs of the taylor series pi = pi - double) (4.0 / (2* i - 1)); // executed second and alternates from there on else { //executed for the positive elements pi = pi + (double) (4.0 / (2* i. 1)); //executed first then alternates printf(" ed: The value of pi is: 9.101f", i, pi);// prints value of pi and number of iterations return 0

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Seven NoSQL Databases In A Week Get Up And Running With The Fundamentals And Functionalities Of Seven Of The Most Popular NoSQL Databases

Authors: Aaron Ploetz ,Devram Kandhare ,Sudarshan Kadambi ,Xun Wu

1st Edition

1787288862, 978-1787288867

More Books

Students also viewed these Databases questions

Question

3. How has e-commerce transformed marketing?

Answered: 1 week ago