Prompting and validation of the input

Assignment Help Business Economics
Reference no: EM131668975

C Program Assignment:

Write an algorithm and program to compute and compute the square root (√). The calculation of the important mathematical constant e and the square root (√) will be done as the sum of an infinite series:

∞                ∞       

e = ∑ 1/n!      &   √S = ∑ xn+1 = 1/2(xn + S/xn)

n=0               n=0

where x0 is the initial "guess"

See https://en.wikipedia.org/wiki/E_(mathematical_constant) and 

https://en.wikipedia.org/wiki/Methods_of_computing_square_roots for details. Use only the Babylonian method for the square root (√).

Output: Output will include your computed value for e, the <math.h> library expected value for e, the number of terms (iterations) it took to reach fifteen decimal-place accuracy, and the time (in nanoseconds) that it takes to compute the constant. Output will also include your computed value for the square root of a value input by the user, the expected value using sqrt(), the number of terms (iterations) it took to reach fifteen decimal-place accuracy, and the time (in nanoseconds) that it takes to compute the square root.

Each set of results above should be displayed so as to allow easy comparison of the computed and expected values. Labels should be included, where appropriate.

Input: Accept user input for the value for which the square root is sought. This number will be a real value, and for this assignment will be limited to a real value >= zero. Prompting and validation of the input is, of course, required.

Requirements:

Efficiency should always be considered. Alway choose the most appropriate loop/decision structures and variable/constant types. Functions should focus on a single task. Main() should be high-level tasks only.

The <time.h> library should be used - see either text index or [K/R] pages 255-256 (Appendix B10) for more details. You may NOT use the math library functions sqrt() or exp() in your computations - directly or indirectly. Instead, use only the delta (difference) of your running computation to determine when to stop. No rounding is permitted.

Program must include (minimum) one function for each computation, in addition to the main program. Other functions developed (likely), as required. Test your program completely.

Reference no: EM131668975

Questions Cloud

Modify the constructor for the fraction class : Modify Constructor for the Fraction class so that GCD is used to reduce fractions immediately. This means that the __add__ function no longer needs to reduce.
The good strategies that you use in decision making : What are the good strategies that you use in decision making? Describe in detail two types of bias can occur in decision making?
Practices does the department of veterans affairs : What ethics policies or practices does the Department of Veterans Affairs have in place?
Determine the optimal amount to spend on radio : Determine the optimal amount to spend on radio and direct-mail advertising. How much in sales will be generated?
Prompting and validation of the input : The calculation of the important mathematical constant e and the square root (v) will be done as the sum of an infinite series:
Optimize the profitability of the organisation : how different functional departments of imperial holdings can synchronize their operations in order to contribute to the competitiveness
Either employee or independent contractor : List the typical form of agency relationship - either employee or independent contractor - and why you think that is true;
Research paper on the underlying issue you chose : Write a research paper on the underlying issue you chose for the applied final project and a description of how parents can deal with issue of the Lot in Life.
Sally have for not wanting her identity to be revealed : Sally asks Hank not to reveal her identity when negotiating for the horse's purchase. WHAT REASONS MIGHT SALLY HAVE FOR NOT WANTING HER IDENTITY TO BE REVEALED?

Reviews

Write a Review

Business Economics Questions & Answers

  Economics assignment

This document contains various important questions and their appropriate answers in the subject field of Economics.

  Demand and supply curves

Economics is the study of the principles governing the allocation of scarce means among competing ends when the objective of the allocation is to maximize the attainment of the ends.

  Long-run perfectly competitive equilibrium for the firm

Evaluate Government intervene and correct this situation?(a) Explain the concept of a concentration ratio. A rise in the price of magarine Explain the impact of external costs and external benefits on resource allocation long-run perfectly c..

  Supply and demand diagrams

Explain each of the following using supply and demand diagrams,  With the use of a graph, explain how these two programs affect cigarette consumption and the price of cigarettes.

  Case study: fisher-price toys

The case study of the Fisher-Price Toys, Inc., a popular case in basic economics and management from the prestigious Harvard Business School.

  Draw the production possibility curve

Draw the production possibility curve and a. Define consumer surplus and producer surplus.

  Tax revenue

The Australian government administers two programs that affect the market for cigarettes

  Maximize total welfare

How many tickets to sell to maximize total welfare.

  Difference between the cv and the ev

The change in consumer surplus (?CS) is not "theoretically" justifiable like the CV and EV but it continues to be the most widely used measure of consumer welfare change. Explain how this can be reconciled

  Depict von neumann-morgenstern utility index u in a diagram

Depict the von Neumann-Morgenstern utility index u in a diagram

  What is the market solution

What is the market solution (market price and quantity) and What is the total surplus of the society under the market solution

  Calculate gross national product and net national product

Calculate gross national product and net national product

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd