Friday 20 September 2013

Friday 20 September 2013

C program for fibonnaci series


C program for displaying elements of FIBONNACI series:

#include <stdlib.h>
#include <stdio.h>

int main(){
    int a[20],i;
    a[0]=1;
    a[1]=1;
    printf("%d ",a[1]);
    for(i=1;i<10;i++){
        a[i]=a[i-2]+a[i-1];
      
        printf("%d ",a[i]);
    }

return 0;
}







Compile and Execute C Online (GNU GCC version 4.7.2)


Executing the program....
$demo
11 2 3 5 8 13 21 34 55 



No comments:

Post a Comment