The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Apr 2017 |
| Last Sign in: | 103 Weeks Ago, 2 Days Ago |
| Questions Answered: | 4870 |
| Tutorials Posted: | 4863 |
MBA IT, Mater in Science and Technology
Devry
Jul-1996 - Jul-2000
Professor
Devry University
Mar-2010 - Oct-2016
For the assignment you worked on earlier, there is some errors. Your solution for Problem 1 of Assignment 2 does not use a function passed as an argument of another function (function pointers). Since this is the topic tested in this problem, I suggest you redo the solution and resubmit before the Monday deadline. The loss of points for late submission of this question is at most 1.5 points, which is substantially less than the loss of points for not following the instructions.
Â
In addition, you communicate the square root to the caller using a global variable. This leads to an automatic loss of 5 points for the problem that uses global variables. Use a function with a return value instead, and eliminate all global variables.Â
Â
CS 170 Computer Science 1: C++Spring Semester 2017Assignment 2Due date: see syllabusCourse weighting 20%This assignment requires you to solve four programming problems, and to implementyour solution in C++. You will be assessed by your final delivery. This is an individualassignment. No collaboration is permitted.Problems:1.Function pointersWrite a functionsquareRootthat uses the Newton’s method of approximate calcu-lation of the square root of a number x. The Newton’s method guesses the square root inxiterations. The first guess is------. In each iteration the guess is improved using2xguess +-----------guess----------------------------as the next guess.2Your main program should prompt the user for the value to find the square root of (x)and how close the final guess should be to the previous guess (for example, 0.001), andpass these values to thesquareRootfunction. As a third argument of the functionsquareRootpass an error processing function, to be called if the other arguments donot pass validation. For example the error processing function can set the wrongarguments to some default values, or ask the user for new values, or do some otherappropriate action. TestsquareRootwith at least two error processing functions.[15 points]2.Functions with variable number of argumentsWrite a functionwritewith variable number of arguments that takes astringfirstargument followed by any number of arguments of typedoubleand prints on thescreen a string formatted by the rules described below. The first argument may containformatsin curly braces of the form{index[:specifier]}, where the square brackets showoptional parts (that is:specifiermay be missing), andindexis the sequence number ofan argument of typedouble(starting from sequence number 0).Rules for formatting:In the printed string the curly brackets and their content will bereplaced by the argument with the given index, formatted according to the givenformat specifier. If the format specifier is missing, the argument will be printed withits default format. For example:write("The number {0} is greater than {1}.", 5.0, -3.0);will printThe number 5 is greater than -3.write("There are no format specifiers here.");will print
Attachments: