Program :-
#include <stdio.h>
main() {
int c,f1=0,f2=1,f,count ;
printf("enter the limit : \n");
scanf("%d",&c);
printf("0 1");
for(count = 3;count <= c; count ++)
{
f = f1 + f2;
printf("%d\t",f);
f1 = f2;
f2 = f;
}
}
Output :-
enter the limit :
5
0 1 1 2 3
#include <stdio.h>
main() {
int c,f1=0,f2=1,f,count ;
printf("enter the limit : \n");
scanf("%d",&c);
printf("0 1");
for(count = 3;count <= c; count ++)
{
f = f1 + f2;
printf("%d\t",f);
f1 = f2;
f2 = f;
}
}
Output :-
enter the limit :
5
0 1 1 2 3
No comments:
Post a Comment