Hello friends!!!!!
Fibonacci series code
C LANGUAGE
8/31/20241 min read
#include<stdio.h>
int main() {
int n;
printf("Enter the number of terms: ");
scanf("%d", &n);
int a = 0;
int b = 1;
if (n == 1) {
printf("%dn", a);
return 0;
}
if (n == 2) {
printf("%d, %dn", a, b);
return 0;
}
printf("%d, %d", a, b);
for (int i = 3; i <= n; i++) {
int sum = a + b;
printf(", %d", sum);
a = b;
b = sum;
}
printf("n");
return 0;
}
Output :
Enter the number of terms: 4
0, 1, 1, 2
=== Code Execution Successful ===