Open EEE2017Assignments opened 4 years ago
No that is not okay. The whole goal of recursion is based on using the local variables so you can't use global variables.
Please check my video i gave a sample code.
You have to call the fibonacci function from the main and print the result in the main function
e.g. printf(fibonacci(3)); // this should print the 3rd term in the fibonacci sequence.
Moreover, you fibonacci function should return an integer (not void) which represents the nth term in the fibonacci sequence.
If you have more questions let me know.
Thank you, TA.
So I changed my code. This is a part of the code included function declaration and main function.
int Fibonacci(int n); int Factorial(int n);
int main() { int n, i;
printf("Enter a single integer: ");
scanf("%d",&n);
for (i = 1;i <= n;i++)
printf("%d ", Fibonacci(i));
printf("\nFactorial of n: %d\n", Factorial(n));
return 0;
}
If there is no problem with that code, then my assignment is okay?
This is correct :)
TA,
I mean in main function I just write ' Fibonacci(n); ' then I can get the output with fibonacci numbers.
This is some part of my Fibonacci function. : void Fibonacci(int n) {
and the end of the function I call next fibonacci function to recurrence. Is it okay to make my fibonacci function to calculate numbers and print the numbers by itself?
This is connected with first question. I declare and be initialization global variables for my fibonacci function. Is it okay?
I always appreciate your efforts!