Question: (a) (6%) When does overflow happen, in other words, at which value of i in the for loop? (i = ?). Lets call that OFI

 (a) (6%) When does overflow happen, in other words, at which

(a) (6%) When does overflow happen, in other words, at which value of i in the for loop? (i = ?). Lets call that OFI (overflow i)

(b) (6%) Why does the overflow happen for that OFI (why there is no overflow for i

(c)(8%) Why when overflow happens, the value displayed is -1474836480?

(d) (6%) Why the next value after overflow happens is -1863462912?

Try enhancement and variations as follows (you can use Nyhoffs C code, or write your own C++ / C# / Java / Python / MATLAB / etc.)

e. (3%) Change / enhance the code of Figure 2.1 or the code in Q3 so that now you are not testing for the number 2 only, but for the nine numbers 2, 3, 4, 5, 6, 7, 8, 9, 10 (which can be an outer loop (int number = 2; number

f. (8%) Find manually when overflow happens in the loop of calculating number *= 10 (like when number = 2). Explain why you think for each of number = 2, 3, 4, .., until 10, that number *= 10 overflows in the loop of iterating 15 times.

g. (6%) Tabulate the results of part (b) of this question.

h. (12+%) Enhance code so that your program breaks out of the for (int i = 0 ; i

i. (4%) Check / verify that the results you get from part (h) agree with what you have from part (f) or (g).

#include using namespace std; int main() { int number = 2; for (int i = 1; i

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!