1. ## recursion code help

hello,
i have tried compiling and running this code but how do i input a numeric value like 30 or 35? this is recursive fibonacci and all i need to do is check the output after program has finished execution. any suggestions would be of tremendous help. i just need to know how to enter a value.

Code:
```#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>

__int64 fibRecursive(int n)
{
if (n <= 0)
return 0;
if (n == 1)
return 1;

return fibRecursive(n - 1) + fibRecursive(n - 2);
}

__int64 fibIteration(int n)
{
__int64 ret =  0;
int i,j, iter;
i=0;
j=1;
if( n < 2)
return n;

for(iter=2; iter<=n; iter++)
{
ret=i+j;
i=j;
j=ret;
}
return ret;
}

int main(int argc, char* argv[])
{
__int64 val;
int n;
time_t t1, t2;
if(argc != 3)
{
printf("Usage %s iteration or recursive number\n", argv[0]);
_exit(1);
}
n = atoi(argv[2]);
t1 = time(NULL);
if(strcmp(argv[1], "iteration") == 0)
{
val = fibIteration(n);
}
else if(strcmp(argv[1], "recursive") == 0)
{
val = fibRecursive(n);
}
t2= time(NULL);
printf("n=%d, Val = %I64u, time spent is =%d\n", n, val, t2 - t1);
return 0;
}```
i want to enter a number, let the program run because all i require is to check how much time it took the program to complete the calculation.

2. First of all, #include <stdint.h> and use int64_t That double underscore stuff is not a good idea in a program.

Second, I find it a little hard to believe you wrote that code (pretty advanced stuff!) without realizing where the input value comes from... doing a little scoop and poop, maybe?

3. You need to pass in the arguments on the command line. See if this helps: Cprogramming.com FAQ > Command line input.

4. ## this isn't my code

i have very basic c language skills.
my only task is to let the code finish executing and note the values because professor wants us to see the difference in time between recursion and iteration calculations.
this isn't hw, just practice code and it was suggested to me that i shouldn't make changes to it prior calculation.

5. Originally Posted by ilikeapplepie
i have very basic c language skills.
my only task is to let the code finish executing and note the values because professor wants us to see the difference in time between recursion and iteration calculations.
this isn't hw, just practice code and it was suggested to me that i shouldn't make changes to it prior calculation.
Ok... we believe you ...

If you actually ran the program you would see the prompt it gives...

6. how do i do command line input on visual c++ 2010? all the code i have ever written used the prompt window after compilation. thanks.

it gives

Usage C: the path filename iteration or recursive number
press any key to continue

7. Originally Posted by ilikeapplepie
how do i do command line input on visual c++ 2010? all the code i have ever written used the prompt window after compilation. thanks.

it gives

Usage C: the path filename iteration or recursive number
press any key to continue
Press and hold the key with the windows symbol on it.
Now type the letter R
Let go of the key with the windows symbol on it
In the Run dialog type CMD
Click OK.

Now you can run your program ....