Compute square roots to a desired degree of accuracy

Assignment Help C/C++ Programming
Reference no: EM13705155

Question 1: You are to write a program which will compute square roots to a desired degree of accuracy.

Begin the program by prompting the user for two numbers: (1) the value for which to determine the square root and (2) the number of decimal places of accuracy desired in the result. For example, find the square root of 7 to four decimal places; the actual value is 2.6458.

On each pass of the inner event-controlled loops, display the current value of ?, the current approximation to the square root, and the error associated with the approximation.

Recall that the iomanip library contains manipulators to format output. At some point prior to the count-controlled loop, use fixed and setprecision(p) to show that floating point results should be displayed in a fixed number format, (nn.nnn and notn.nnE+nn), and that p decimal positions should be shown, even if all are trailing zeroes.

This need only be done once as fixed and setprecision will remain in effect until reset.

Use setw(w) to display a value in a total of w columns; this must be done for each individual value.

Reference no: EM13705155

Questions Cloud

Discuss the tcp and the udp application layer protocol : Discuss the TCP and the UDP application layer protocol. (the differences, advantages and disadvantages, services provided)
Data transmission protocol : A certain data transmission protocol the parity error detection concept is used. what does this mean?
An application-level and a circuit-level one : What is a gateway, and what is the difference between an application-level and a circuit-level one?
Futures of anomaly based instruction detection scheme : Explain the futures of anomaly based instruction detection scheme.
Compute square roots to a desired degree of accuracy : write a program which will compute square roots to a desired degree of accuracy.
What is the total file transfer time : How many packets must be transmitted to accomplish the file transfer - What is the total file transfer time.
Explain how many photons are produced each second : Problem- A typical 100-watt light bulb consumes 100J of energy per second. If a light bulb converts all of this energy to 500nm light, how many photons are produced each second
Evaluate a polynomial at a given real value : Write a function to evaluate a polynomial at a given real value a.
Create a function gcd : Create a function gcd(a, b) that receives two integers and returns the greatest common denominator of the two integers.

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Objectivein this assignment you read a list of employees

objectivein this assignment you read a list of employees from a csv file and convert them into corresponding objects.

  Ansi-c program complete assignment as per written in the

complete assignment as per written in the attached

  Assume we have an array named $students

Assume we have an array named $students. Each entry in the array contains a student's full name (e.g. "Jane Smith"). Write the PHP code needed to display all students (in the array) whose first name starts with the letter "J".

  Taskimplement class serial using serialcpp and serialh- the

taskimplement class serial using serial.cpp and serial.h- the function call operator is overloaded and will generate a

  Write a recursive void function

Write a recursive void function called rot at eLeft that rotates the first n integers in an array to the left. To rotate n items left, rotate the first n - 1 items left recursively, and then exchange the last two items. For example, to rotate the ..

  Calculates the average of those numbers

Write a C program which takes n number of element from user (where, n is specified by user), stores data in an array and calculates the average of those numbers. Output of the program should look like this;

  Ansi-c program which allows the user to play a game

Your task is to write an ANSI-C program which allows the user to play a game. This will require I/O from both the user and from ?les.

  The staffs need a program that can determine

The staffs need a program that can determine whether children have been naughty or nice. individual data files(can be any name) for each childred are available that consist of 368(365+3)integer number each.

  A file (complex.txt) which has a number of complex numbers

Read in a file (complex.txt) which has a number of complex numbers in the form of a+bi (e.g. 3+5i  2-3i etc).

  Create a program that uses the vanderwaals equation

Write a program that uses the VanderWaals equation of state and the perfect gas law to display in tabular form the relationship between the pressure and the volume of n moles of a gas at a constant absolute temperature, T, over a range of volumes.

  What output would be produced by the program segment

What output would be produced by the following program segment?

  Write a c function void print_triangle(int n)

Write a C function void print_triangle(int n) that prints a triangular pattern of asterisks of height n and width 2 * n + 1 with one asterisk in the first line, three in the second line, etc.,

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