#include<stdio.h>
main()
{
int first = 0, second = 1, i, n, sum = 0;
printf("Enter the number of terms: ");
scanf("%d", & n);
printf("Fibonacci Series:\n");
for (i = 1; i <= n; i++)
{
if (i == 1)
{
sum = 1;
} else
{
sum = first + second;
first = second;
second = sum;
}
printf("%d - %d\n", i, sum);
}
}
Note: Need to be arranged in compiler after copied
OutPut:
Enter the number of terms: 15
Fibonacci Series:
1 - 1
2 - 1
3 - 2
4 - 3
5 - 5
6 - 8
7 - 13
8 - 21
9 - 34
10 - 55
11 - 89
12 - 144
13 - 233
14 - 377
15 - 610