Monday, 24 December 2012

Printing the Fibonacci series:

Program for Printing the Fibonacci series:


#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c,range,i=2;
clrscr();
printf("Enter How many numbers you want to get printed:");
scanf("%d",&range);
a=0;
b=1;
printf("%d,%d",a,b);
while(i!=range)
{
c=a+b;
a=b;
b=c;
i=i+1;
printf(",%d",c);
}
getch();
}

and the output is like:

0 Responses to “Printing the Fibonacci series:”

Post a Comment

Recent Comments

All Rights Reserved Assignments on C language