#include <stdio.h>
int main() {
int n, t1 = 0, t2 = 1, nextTerm;
printf("Enter the number of terms: ");
scanf("%d", &n);
printf("Fibonacci Series up to %d terms: \n", n);
for (int i = 1; i <= n; ++i) {
if (i == 1) {
printf("%d, ", t1);
continue;
}
if (i == 2) {
printf("%d, ", t2);
continue;
}
nextTerm = t1 + t2;
t1 = t2;
t2 = nextTerm;
if (i == n) {
printf("%d", nextTerm);
} else {
printf("%d, ", nextTerm);
}
}
return 0;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: