Fibonacci series C program

It’s a Fibonacci series C program that inputs any number of terms from the user, and print result on the screen.

To understand this program, it’s better you should know the following topics:

Program (1): to print Fibonacci series and the user will enter the number of terms to be displayed.

#include<stdio.h>
#include<conio.h>
void main()
{
int a,i,b1=0,b2=1,num;
printf("Enter number of terms to be print: ");
scanf("%d",&num);
printf("the fibonacci series is\n");
printf("%d\n",b1);
printf("%d\n",b2);
for(i=3;i<=num;i++)
{
a=b1+b2;
b1=b2;
b2=a;
printf("%d\n",a);
}
getch();
}

Output (1)

Enter number of terms to be print: 4
the fibonacci series is
0
1
1
2

Published by

Electrical Workbook

We provide tutoring in Electrical Engineering.

Leave a Reply

Your email address will not be published. Required fields are marked *