Question: computeSqrt.cpp #include sqrt.h#include #include using namespace std; int main(int argc, char** argv){if (argc != 2) { cerr < < Usage: < < argv[0] <

computeSqrt.cpp
#include "sqrt.h"#include #include
using namespace std;
int main(int argc, char** argv){if (argc != 2) { cerr << "Usage: " << argv[0]<< " number" << endl; return -1; }
double d = atof(argv[1])cout << computeSqrt(d, 0.0001) << endl;
return 0;}
sqrt.cpp
#include "sqrt.h"#include
using std::abs;
/*** Compute the square root of x, with an accuracy of* plus or minus eps*X.*/double computSqrt (double x, double eps){if (x <= 0.0) return x;
double limit = eps*x;double minLimit = 0.00000001*x;if (minLimit > limit) limit = minLimit;
double guess = x / 2.0;double lastGuess = x + 2.0*limit;// Newton Raphson methodwhile (abs(guess - lastGuess) > limit){ lastGuess = guess; guess = 0.5 * (guess + x / guess);}return guess;}
sqrt.h
#ifndef SQRT_H#define SQRT_H
/*** Compute the square root of x, with an accuracy of* plus or minus eps*X.*/double computeSqrt (double x, double eps);
#endif
Need help 3 to 5- PLEASE DON'T COPY AND PASTE FROM OTHERSOLUTIONS, IF YOU DON'T KNOW THEN JUST DON'T ANSWER!!
1 The Assignment 1. Create a directory ~/UnixCourse/compileAsst 2. Copy the files from ~cs252/Assignments/sqrt/ 3. Compile the code, capturing the error messages by any of the techniques covered in this module's lesson. Fix any errors that you encounter. Continue compiling and fixing until you are able to produce an executable program named computeSqrt. o Each error can be fixed by a change of no more than 2 characters on a a single line each. If you find yourself doing anything more complicated, stop! (You may well be giving incorrect compilation commands.) 4. This program computes square roots of positive numbers. It expects to receive a floating point number as a command line parameter when run, e.g., ./computeSqrt 6.25 into your newly created directory. (Do not copy the sqrt directory itself.) Test the program on a few numbers to be sure it works. 5. Write a shell script named sqrts.sh that will take a list of numbers as command line parameters and will run computesqrt on each of them in turn, however many there are. For example, the output of ./sqrts.sh 6.25 25 100 should be 2.5 5 10 1 The Assignment 1. Create a directory ~/UnixCourse/compileAsst 2. Copy the files from ~cs252/Assignments/sqrt/ 3. Compile the code, capturing the error messages by any of the techniques covered in this module's lesson. Fix any errors that you encounter. Continue compiling and fixing until you are able to produce an executable program named computeSqrt. o Each error can be fixed by a change of no more than 2 characters on a a single line each. If you find yourself doing anything more complicated, stop! (You may well be giving incorrect compilation commands.) 4. This program computes square roots of positive numbers. It expects to receive a floating point number as a command line parameter when run, e.g., ./computeSqrt 6.25 into your newly created directory. (Do not copy the sqrt directory itself.) Test the program on a few numbers to be sure it works. 5. Write a shell script named sqrts.sh that will take a list of numbers as command line parameters and will run computesqrt on each of them in turn, however many there are. For example, the output of ./sqrts.sh 6.25 25 100 should be 2.5 5 10
Step by Step Solution
There are 3 Steps involved in it
Answer Heres the 4 files that you need computeSqrtcpp include sqrth include include using namespace ... View full answer
Get step-by-step solutions from verified subject matter experts
