Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Implement Herons Method In the q01 folder, edit the C++ console application to calculate and display the square root of a random integer greater than

Implement Herons Method

In the q01 folder, edit the C++ console application to calculate and display the square root of a random integer greater than one million, using Heron's Method, to 8 digits of precision to the right of the decimal point.

Specifically you must implement the missing code in the function heron() to return the estimate of the square root of the parameter s.

You may stop iterating when your current x^2 estimate is within 1 x 10 ^ -06 of s

#include "stdafx.h"

using namespace std;

double herons(double s) { double x = s / 2; // TODO: Insert your code here (no greater then e-6 return x; }

int main() { seed_seq seed{ 2016 }; default_random_engine generator{ seed }; uniform_int_distribution<> distribution(1e6, 2e6);

double s = distribution(generator);

cout << fixed << setprecision(0) << "The square root of " << s << " is " << setprecision(8) << herons(s) << endl << endl;

return 0; }

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

Step: 3

blur-text-image

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

DB2 11 The Ultimate Database For Cloud Analytics And Mobile

Authors: John Campbell, Chris Crone, Gareth Jones, Surekha Parekh, Jay Yothers

1st Edition

ISBN: 1583474013, 978-1583474013

More Books

Students also viewed these Databases questions

Question

=+1 What are the major issues related to international T&D?

Answered: 1 week ago