Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You will be creating a main() function to practice basic loops, basic user inputs, and basic outputs. You will submit ONE file on Canvas called

image text in transcribed

You will be creating a main() function to practice basic loops, basic user inputs, and basic outputs. You will submit ONE file on Canvas called LastName_Firstname_HW1F.cc (or.cpp). Instructions: 1. Prompt a user to type in a positive integer from the keyboard. (Examples: 1, 2, 5, 10, 15) 2. Compute sum1 = 1/12 + 1/22 + 1/32 + + 1? Use float to compute your answer. Note that this will result in a maximum accuracy of 7 digits. 3. Instead of printing this sum (approximately 1.64) compute the following expression: result1 = sqrt(6 * sumi) In order to use the sqrt function you will have to #include 4. Output resulti. You may recognize the number you get from this. But it will not be very accurate. 5. Compute a new result (result2) the same way using a very large value for n. Compute a new result (result3) backwards using the same very large value for n. sum3 = 12 + + 1/32 + 1/22 + 1/12. ... 6. Output result2 and results. This is all you have to submit, but you should try to figure out which of these two numbers is more accurate. It should be fairly obvious which answer is better as n increases. Figure out how many iterations you will need before the contribution of 12 is too small and no longer matters. We will discuss in class. Example output: result1 = X.XXXXXX result2 = X.XXXXXX result3 = X.XXXXXX

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_2

Step: 3

blur-text-image_3

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

Hands-On Database

Authors: Steve Conger

2nd Edition

0133024415, 978-0133024418

More Books

Students also viewed these Databases questions

Question

=+ d. a professor deciding how much to prepare for class

Answered: 1 week ago