Calculating the maximum and minimum time needed to run a program

In my Programming assignment, I have to use a program provided by my instructor of Fibonnaci numbers and alter it so that instead of showing the amount of time it takes to run the program (Using GetTickCount()), it has to return the maximum and minimum time for each number in the series to be calculated by both Recursive and iterative methods. This is the code:


#include "FiboImp.h"

#include <windows.h>

const int MAXN(45);

int main()
{
unsigned long int before, after, diff, result;

cout << "Execution time for Fibonacci no. implementions (ms)\n";
cout << setfill('+') << setw(64) << "+" << endl << setfill(' ');
cout << setw(4) << "n" << setw(20) << "Recursive"
<< setw(20) << "Iterative" << endl;
cout << setfill('+') << setw(64) << "+" << endl << setfill(' ');
for (int n=0; n<=MAXN; n++) {
cout << setw(4) << n;
before=GetTickCount();
result=FiboRecursive(n);
after=GetTickCount();
diff=after-before;
cout << setw(12) << result << setw(13) << "(" << diff << " --- " << diff << ")";
before=GetTickCount();
result=FiboIterative(n);
after=GetTickCount();
diff=after-before;
cout << setw(12) << result << setw(13) << "(" << before << " --- " << after << ")";
cout << endl;
}

return 0;
}


This is the code with my own edits already applied
So basically, I'm absolutely stumped. Any help would be appreciated!!
Last edited on
Suggest you place your code in b/n code tags to make it easier to read.
Does it compile? What output do you get? Also someone may want to look at the two functions.
Topic archived. No new replies allowed.