Saturday 8 April 2017

C Program to Print Fibonacci Series up to a Limit

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

No comments:

Post a Comment

How to Invert an SVG image using CSS ?

You can invert your svg easily by using following css code svg { -webkit-filter: invert(100%); /* safari 6.0 - 9.0 */ filter...