P055.c
Problem Statement
P055.c
WAP to print n terms of Fibbonacci Series (Starting from term 0)
Source Code
c
#include <stdio.h>
void printFibonacci(int);
void printFibonacci(int n)
{
int val1 = 0, val2 = 1, val3, i;
printf("\nFibonacci series upto %d terms :", n);
if (n < 0)
printf(" N/A");
if (n == 0)
printf(" %d", val1);
if (n > 0)
printf(" %d %d", val1, val2);
for (i = 2; i <= n; i++)
{
val3 = val1 + val2;
printf(" %d", val3);
val1 = val2;
val2 = val3;
}
}
int main()
{
int n;
printf("Enter the n : ");
scanf("%d", &n);
printFibonacci(n);
return 0;
}1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
● Author - Amit Dutta · Updated - 12 Dec 2025