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

  Number of the academic publishers of electronic journals

You have insider knowledge and many contacts at a large number of the academic publishers of electronic journals. You also have experience from the academic library side of the business. So, you have decided that you want to use today’s computing res..

  Utility function-demand for x and y as functions

Martha has the utility function U(x, y) = min {4x,2y}. Write down her demand for x and y as functions of the variables m, px, and py, where m is income, px is the price of x, and py is the price of y.

  In spite of professed efforts to remain unbiased

In spite of professed efforts to remain “unbiased,” it is generally accepted that almost all new sources contain bias in some form. Describe the different kinds of bias that exist in news sources. Why is it important to be aware of media bias?

  Relationships in energy consumption-financial development

Modelling the Relationships between Energy Consumption, Financial Development, and Economic Growth in Nigeria from 1980 - 2015: Evidence from Cointegration with Unknown Structural Breaks

  Identify if the demand or the supply curve is misplaced

identify if the demand or the supply curve is misplaced and whether it is too far to the left or too far to the right.

  Supply curve shifts more than the demand curve

Assume that the demand curve for DVD players shifts to the left and the supply curve for DVD players shifts to the? right, but the supply curve shifts more than the demand curve.

  Observe between years to maturity-yield to maturity

Consider a bond with a 4% annual coupon and a face value of $1,000. Complete the following table. Years to Maturity Yield to Maturity Current Price 2 2% 2 4% 3 4% 5 2% 5 6% What relationships do you observe between years to maturity, yield to maturit..

  The probability that any given unit will operate

The probability that any given unit will operate for at least (1) 39 months, (2) 48 months, (3) 60 months. (Enter your answer to 4 decimal places using probabilities shown in the above table.)

  Determine the net present worth of the equipment

A company plans to invest $12,000 dollars on new equipment with an 8 year life to reduce operating costs. It is estimated that the savings will be $4,000 the first year but decrease by $400 each year for the remainder of the equipment's life. Determi..

  Q1 would elasticity be constant for the demand curve

q1. would elasticity be constant for the demand curve represented by the equation q5000-0.5p?whyq2. if the cost

  Unemployment rate have on the equilibrium wage

There are concerns about an increase in unemployment due to the slowdown in manufacturing. a) What effect would an increase in the unemployment rate have on the equilibrium wage?

  Rapid growth of your technology company

Because of the rapid growth of your technology company, the executive team has asked HR to develop an internal training program.

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