Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please write C not C++ Rules You can use all course material and man pages, but you should be able to solve the problems below

Please write C not C++

image text in transcribedimage text in transcribed

Rules You can use all course material and man pages, but you should be able to solve the problems below without web searches or communicating with other students. In the final exam you will be asked to solve similar problems... Your programs must compile without warning using gcc -g -Wall Wextra -Wconversion -Wsign-conversion -0 ... on our lab machines. If there are compiler warnings or errors, there will be considerable mark deductions Test your programs with different values. For now, the speed of your programs is irrelevant. So don't spend time on optimization Your programs must be well structured. Use ctrl-x t in Emacs or a similar command in your editor of choice to pretty-print them. Marks are assigned to functionality and program appearance In case your program hangs, use ctrl-c to terminate it Download README.txt and fill in the requested information Submit README.txt p1.c p2.c on eClass by the due date You can submit as often as you want. We will only consider the last submission for marking Problem 2: Fast Approximation of it You may recall from calculus courses that a 3.14159265358979323846264338327950288419716939937... - the ratio of the circumference and the diameter of a circle - is an irrational number, which means that it can't be represented as a ratio of two integers. Consequently, we can only try to approximate it Write C program p2.c that approximates at based on floating point arithmetic (type double) using the following identity: 4 2 1 T = 1 1 8i + 6' 16 82 +1 82 +4 8i + 5 i=0 Sum up the values for i=0,1,.. until the sum doesn't change anymore and print the sum variable and its absolute difference to 3.1415926535897932 in each iteration using the %.20f format specifier for all double values Also, comment your program and format it well

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

Intranet And Web Databases For Dummies

Authors: Paul Litwin

1st Edition

0764502212, 9780764502217

More Books

Students also viewed these Databases questions

Question

A rating instrument linked to job duties and responsibilities

Answered: 1 week ago