C Program to print Fibonacci series up to 100

Fibonacci Series is a series of numbers in which each number ( Fibonacci number ) is the sum of the two preceding numbers starting with 0 and 1.

Logic: Initialize first and second number as 0 and 1 Print the first and second number third number will be sum of first and second Fourth number will sum of second and third and so on

				
					#include<stdio.h> 
#include<conio.h> 
void main() 
{ 
int a=0,b=1,c=0,i; 
clrscr(); 
printf("%d\t%d\t",a,b); 
for(i=0;i<=10;i++) 
{ 
c=a+b; 
if(c<100) 
{ 
printf("%d\t",c); 
} 
a=b; 
b=c; 
} 
getch(); 
}
				
			
******************* 
Output: 
0 1 1 2 3 5 8 13 21 34 55 89 
********************

Leave a Reply