#include<stdio.h>
#include<conio.h>
void main()
{
int f1=0, f2=1, f3, num, count=0;
clrscr();
printf("\nEnter a Number: ");
scanf("%d", &num);
printf("\n%d",f1);
printf("\n%d",f2);
count=2;
while(count<num)
{
f3=f1+f2;
count++;
printf("\n%d",f3);
f1=f2;
f2=f3;
}
getch();
}
OUTPUT:
Enter a Number: 10
0
1
1
2
3
5
8
13
21
34
#include<conio.h>
void main()
{
int f1=0, f2=1, f3, num, count=0;
clrscr();
printf("\nEnter a Number: ");
scanf("%d", &num);
printf("\n%d",f1);
printf("\n%d",f2);
count=2;
while(count<num)
{
f3=f1+f2;
count++;
printf("\n%d",f3);
f1=f2;
f2=f3;
}
getch();
}
OUTPUT:
Enter a Number: 10
0
1
1
2
3
5
8
13
21
34
Comments
Post a Comment