subject

Debug a function called SumBetween() which takes two integer inputs, low and high. This function should calculate the sum of all integers between low and high inclusive. Example: SumBetween(1,10) should return 55. SumBetween should throw std::invalid_argument if low and high are out of order. SumBetween should throw std::overflow_error if the sum exceeds the maximum/minimum value of int. INT32_MAX is the maximum value of a 32-bit integer. INT32_MIN is the minimum value of a 32-bit integer. The function prototype is int SumBetween(int low, int high). Only use int. Don't use a bigger type (it can work, but is not in the spirit of the problem). HINT 1: Say a and b are two positive integers such that (a b) results in an overflow. To form conditions for overflow_error, consider using subtraction expressions (INT32_MAX - a or INT32_MAX - b) instead of addition. Likewise, think about forming conditions with INT32_MIN. HINT 2: Can you readjust low and high so that you can avoid overflow during calculating the sum? For example, if low = INT32_MIN (-2147483648) and high = INT32_MAX (2147483647), values except -2147483648 do not need to be summed at all. START by correcting the syntax error(s), If any. 1- int SumBetween(int low, int high) { 2 int value 0; 3. for (int n low; n < high; n++) { 4 value += n; 5 } 6 return value; 7 }

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 02:50
Define a class named movie. include private fields for the title,year, and name of the director. include three public functions withprototypes void movie: : settitle(cstring); , voidmovie: : setyear(int); , void movie: : setdirector(string); . includeanother function that displays all the information about a movie.write a main() function that declares a movie object namedmyfavoritemovie. set and display the object's fields.this is what i have but know its wrong since it will notcompile: #include#includeusing namespace std; //class declarationclass movie{private: string movietitle ; string movieyear; string directorname; public: void settitle(string title); void setyear(string year); void setdirector(string director); void displayinfo(); }; //class implementationvoid movie: : settitle(string title){ movietitle = title; cout< < "what is the title of themovie? "< > temp; myfavoritemovie.settitle(temp); cout< < "enter movie year"< > temp; myfavoritemovie.setyear(temp); cout< < "enter director'sname"< > temp; myfavoritemovie.setdirector(temp); //display all the data myfavoritemovie.displayinfo(); system("pause"); return 0; this code is not entirely mine someone on cramster edited my firstcode but then i try manipulating the new code and i still get acompile error message : \documents\visual studio 2008\projects\movie\movie\movie.cpp(46) : error c2679: binary '< < ' : no operator found which takes aright-hand operand of type 'std: : string' (or there is no acceptableconversion)c: \program files (x86)\microsoft visual studio9.0\vc\include\ostream(653): could be'std: : basic_ostream< _elem,_traits> & std: : operator< < > (std: : basic_ostream< _elem,_traits> & ,const char *)w
Answers: 1
question
Computers and Technology, 23.06.2019 14:30
Norder to receive financial aid at his vocational school, mario must fill out the fafsa. the fafsa is a form that must be completed to determine . in order to complete a fafsa, you must submit . the fafsa can students obtain
Answers: 2
question
Computers and Technology, 23.06.2019 16:30
What is one reason why indoor air pollution has become an increasing problem.
Answers: 1
question
Computers and Technology, 24.06.2019 03:30
Other - a written response, no less than arial 12-point font, to the following: of the following, which would you consider is most important to customer service goals? choose one and explain why. (1) accuracy (2) punctuality and attendance (3) courtesy (4) productivity (5) organization
Answers: 1
You know the right answer?
Debug a function called SumBetween() which takes two integer inputs, low and high. This function sho...
Questions
question
Mathematics, 17.02.2020 18:12
question
Chemistry, 17.02.2020 18:12
question
English, 17.02.2020 18:13
Questions on the website: 13722367