469,609 Members | 1,455 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,609 developers. It's quick & easy.

Help me for App.Compute Time -urgent

I have a code, where I should compute the App.Compute Time, for n=1,5,10,20,30,40,50.Is there any GOOD EXPERT that can make this clear to me ? If yes than PLease write here
The code is:
Expand|Select|Wrap|Line Numbers
  1. #include <iostream>
  2. using namespace std;
  4. int fib (int n)
  5.     {
  6.     if (n<3)
  7.         return (1);
  8.     else
  9.            return (fib(n-2)+fib(n-1));
  10.     }
  11. int main()
  12. {
  13. cout<<"Fibbonaciu Numbers: 1, 1, 2, 3, 5, 8, 13, 21,...\n"<<endl;
  14. int n, Result;
  15. cout<<"n = ";    cin>>n;
  16. Result=fib(n);
  17. cout<<"\n\tfib ( "<<n<<" ) = "<<Result;
  18.     cin.get(); cin.get();
  19.     return 0;
  20. }
Apr 9 '07 #1
2 1281
4,677 Expert Mod 4TB
I'm sorry, I don't understand your question. You ask for some sort of timing function, but do you mean actual system time, or a set of numbers/levels for your fib. sequence?

As well, what have you tried on this?
Apr 9 '07 #2
5,000 Expert 4TB
I think what the OP is asking is they want to calculate the time it takes to do this calculation in real time.

For this you want to get the current system time in milliseconds before you begin your fib calculation loop. Then you will again get the system time after you exit your loop. You can then subtract these values to get the real time run time of your application.
Apr 9 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

3 posts views Thread by jack | last post: by
4 posts views Thread by Dino Buljubasic | last post: by
11 posts views Thread by Schizoid Man | last post: by
23 posts views Thread by Tiny Tim | last post: by
21 posts views Thread by asif929 | last post: by
9 posts views Thread by xxbabysue123xx | last post: by
8 posts views Thread by =?Utf-8?B?QWw=?= | last post: by
reply views Thread by Solution2021 | last post: by
reply views Thread by devrayhaan | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.