for (i=1;i<=10000;++i) printf("%d %d %d\n",i, i*i, i*i*i);
(void) time(&t2);
printf("\nTime to do 300 squares and cubes= %d seconds\n", (int) t2); printf("\nTime to do 300 squares and cubes= %d seconds\n", (int) t1); printf("\nTime to do 300 squares and cubes= %d seconds\n", (int) (t2-t1));
#include < stdio.h >
ReplyDelete#include < sys/types.h >
#include < time.h >
int main()
{ int i;
time_t t1,t2;
(void) time(&t1);
for (i=1;i<=10000;++i) printf("%d %d %d\n",i, i*i, i*i*i);
(void) time(&t2);
printf("\nTime to do 300 squares and cubes= %d seconds\n", (int) t2);
printf("\nTime to do 300 squares and cubes= %d seconds\n", (int) t1);
printf("\nTime to do 300 squares and cubes= %d seconds\n", (int) (t2-t1));
getchar();
return 0;
}