Suppose you compile and run the following micro-benchmark
main() {
float f = 1.0;
for (int i=0; i<1000000; ++i) f = f * f;
}
That code ran very fast, so you change the loop termination condition from i<1000000 to i<1000000000 to make it take longer to run, and recompile the program. Oddly, the new version takes exactly the same amount of processor time to execute. What probably happened?
C++ language:-
Bjarne Stroustrup developed the general-purpose, free-form programming language C++ in 1979 at Bell Labs in Murray Hill, New Jersey, as an improvement to the C language. It is frequently referred to as C with classes because it is a C extension. It was specially created with a focus on huge systems and resource-constrained software. Since its start, C++ has grown a lot.
Step by stepSolved in 6 steps with 2 images
- using Python code only. You are given N sticks, where the length of each rod is a positive number. The cutting work is done on the sticks so that they are all reduced to the length of the smallest rod. Suppose we have six sticks of the following length: 544228 Then, in a single cutting operation we cut 2 lengths from each of the six sticks. In the following cut-off operation, there are four sticks (not the length of an egg), the length of which is as follows: 3 2 26 The above step is repeated until there are no sticks left. If you are given the length of the N sticks, print the number of sticks left before each subsequent cutting operation using C++ code only. Input 6 544228 Output 6 4 2 1arrow_forwardPlease Give me answer fast.arrow_forwardImplement the modular exponentiation (a.k.a. fast exponentiation)function mod_exp (b, n, m) to compute bn (mod m) more efficiently. (Hint: toread n bit-by-bit, use / and % operations repeatedly)a) Test your function for b = 3, n = 231 – 2, m = 231 – 1.b) Report the result and the time (in seconds) it takes to find the result. in pahtonarrow_forward
- Evaluate the performance per linearrow_forwarda. for (int i = 0; true; i++) System.out.println (a[i]); b. for (int i = 0; true; i++) ; System.out.println (a[i]); c. for (int i = 0; i <= a.length; i++) System.out.println (a[i]); d. for (int i = 1; i <= a.length ; System.out.println (a[i-1]); 1) Which loop statement outputs the elements of array 'a'? 2/7 e. None of the above ... ...arrow_forwardPlease make a Python code which can generate a multiplication table given input n.arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education