how to write Fibonacci sequence using C programming Language !
#include <stdio.h>
#include <math.h>
void main (){
int fib[] = {0,1};
int n,i;
scanf("%d",&n);
for(i = 0;i<n;i++){
printf("%d\n",fib[0]);
int fib_2 = fib[0] + fib[1];
fib[0] = fib[1];
fib[1] = fib_2;
}
}
Comments
Post a Comment