A Program To Print Fibonacci Series Using Functions

#include<stdio.h>
#include<conio.h>
main()
{
void fib(int);
int n;
clrscr();
printf("Enter how many terms u want:");
scanf("%d",&n);
fib(n);
getch();
}
void fib(int n)
{
int a=0,b=1,c,i;
printf("The Fibonacci Series is:%2d %2d",a,b);
for(i=2;i<n;i++)
{
c=a+b;
a=b;
b=c;
printf("%4d",c);
}

No comments:

Post a Comment

Copyright © EduRAR @ www.edurar.blogspot.in