#include <stdio.h>
// Function to calculate the nth Fibonacci number using recursion
int fibonacci(int n) {
if (n <= 1) {
return n;
} else {
return fibonacci(n - 1) + fibonacci(n - 2);
}
}
// Function to print the Fibonacci series up to n terms using recursion
void printFibonacci(int n) {
for (int i = 0; i < n; i++) {
printf("%d ", fibonacci(i));
}
}
int main() {
int terms;
printf("Enter the number of terms: ");
scanf("%d", &terms);
printf("Fibonacci series up to %d terms:\n", terms);
printFibonacci(terms);
return 0;
}
This program first defines a function fibonacci to calculate the nth Fibonacci number recursively. Then, it defines another function printFibonacci to print the Fibonacci series up to n terms by calling the fibonacci function. Finally, in the main function, it takes input from the user for the number of terms and prints the Fibonacci series up to that number of terms.