All major conceptual S2 C-Programs with Algorithms
#include <stdio.h>
// Function to calculate Fibonacci number using recursion
int fibonacci(int n) {
if (n <= 0) {
return 0;
} else if (n == 1) {
return 1;
} else {
return fibonacci(n - 1) + fibonacci(n - 2);
}
}
int main() {
int n;
printf("Enter the number of terms: ");
scanf("%d", &n);
printf("Fibonacci series:\n");
for (int i = 0; i < n; i++) {
printf("%d\n", fibonacci(i));
}
return 0;
}