Hello world,
I would be very gracefull if someone could send me a program with some math algorithms, which calculates smth (no matter what) but do it long, for some seconds. Please help for c newbie.
Thanks
Hello world,
I would be very gracefull if someone could send me a program with some math algorithms, which calculates smth (no matter what) but do it long, for some seconds. Please help for c newbie.
Thanks
Here you go:
Code:#include <time.h> int main(void) { time_t start = time(0); while (difftime(time(0), start) < 3); return 0; }
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
This calculates the number 2 (as the sum of 2 integers) but it takes a while to do so.Code:#include <stdlib.h> #include <stdio.h> #include <ctype.h> #include <string.h> int main(){ int i; int j; int k; for(i = 0; i < 30000; i++) for(j = 0; j < 30000; j++) for(k = 0; k < 30000; k++){ } printf("%d", 1+1); return 0; }
Hope is the first step on the road to disappointment.
Aww... this thread is becoming like my nickname....
thanks for that
But it be nice if code would be ~100 or more lines..
Looks like you did not get the drift. Read the homework guidelines and do your own homework before asking for help.Originally Posted by auryc
*thread closed*
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)