Suppose you compile and run the following micro-benchmark program in an attempt to see how quickly floating-point multiplications are computed. 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?
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 step
Solved in 6 steps with 2 images