Ex:6 Linker
Main program:
#include<stdio.h>
#include<conio.h>
#include"fib.c"
void main()
{
clrscr();
printf("Fibonacci series\n");
fib();
getch();
}
Fibonacci series:
#include<stdio.h>
#include<conio.h>
void fib()
{
int f1=0,f2=1,f3,n,i;
printf("Enter the no. of terms ");
scanf("%d",&n);
printf("%d\n%d\n",f1,f2);
for(i=2;i<n;i++)
{
f3=f1+f2;
printf("%d\n",f3);
f1=f2;
f2=f3;
}
getch();
}
Output:
Fibonacci series
Enter the no. of terms 8
0
1
1
2
3
5
8
13
No comments:
Post a Comment