mirror of https://github.com/TheAlgorithms/C
add commandline option to FibonacciDP.c
This commit is contained in:
parent
90e6ee0771
commit
fce50a9d7c
|
@ -31,12 +31,17 @@ int fib(int n)
|
|||
return f[n];
|
||||
}
|
||||
|
||||
int main(){
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int number;
|
||||
|
||||
//Asks for the number/position of term in Fibonnacci sequence
|
||||
if (argc == 2)
|
||||
number = atoi(argv[1]);
|
||||
else {
|
||||
printf("Enter the value of n(n starts from 0 ): ");
|
||||
scanf("%d", &number);
|
||||
}
|
||||
|
||||
printf("The nth term is : %d \n", fib(number));
|
||||
|
||||
|
|
Loading…
Reference in New Issue