Deitel & Deitel, C How to Program 6th Edition, Exercise 3.37
/*3.37 (How Fast is Your Computer?) How can you determine how fast your own computer really
operates? Write a program with a while loop that counts from 1 to 300,000,000 by 1s. Every time
the count reaches a multiple of 100,000,000, print that number on the screen. Use your watch to
time how long each 100 million repetitions of the loop takes.*/
#include <stdio.h>
int main() {
int a = 0, b, c;
while (a < 100000000)
a++;
printf("a is %d right now\n", a);
while (a < 200000000)
a++;
printf("a is %d right now\n", a);
while (a < 300000000)
a++;
printf("a is %d right now\n\n", a);
return 0;
}
operates? Write a program with a while loop that counts from 1 to 300,000,000 by 1s. Every time
the count reaches a multiple of 100,000,000, print that number on the screen. Use your watch to
time how long each 100 million repetitions of the loop takes.*/
#include <stdio.h>
int main() {
int a = 0, b, c;
while (a < 100000000)
a++;
printf("a is %d right now\n", a);
while (a < 200000000)
a++;
printf("a is %d right now\n", a);
while (a < 300000000)
a++;
printf("a is %d right now\n\n", a);
return 0;
}
Let me know in the comments if this page helped you somehow.
It is nice to know if my work helped someone, thanks :)
Comments
Post a Comment