mirror of
https://github.moeyy.xyz/https://github.com/TheAlgorithms/C.git
synced 2023-10-11 15:56:24 +08:00
add commandline option to FibonacciDP.c
This commit is contained in:
parent
564ef7ad6d
commit
959e25ca08
@ -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
|
||||
printf("Enter the value of n(n starts from 0 ): ");
|
||||
scanf("%d", &number);
|
||||
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
Block a user