P055.c ​
Metadata ​
- Author — Amit Dutta (amitdutta4255@gmail.com)
- Last updated — 12 Dec 2025
- License — MIT
Problem Statement ​
Problem Statement
WAP to print n terms of Fibbonacci Series (Starting from term 0)
Source Code ​
Printing the code
To print this file, open it on GitHub and click Raw before printing, or use the Download Raw button above and print directly from that page.
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