Answered step by step
Verified Expert Solution
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
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started