FIBONACCI SERIES
Code :
#include<stdio.h>
int main()
{
int prev = 0,n_num=0,count=0, n,curr = 1;
printf("=======================================\n");
printf("\t FIBONACCI SERIES\n");
printf("=======================================\n");
printf("Enter maximum limit of sequence : ");
scanf("%d", &n);
printf("\n");
printf("Fibonacci series upto %d terms are,\n\n", n);
printf("%d %d ", prev,curr);
while(count < (n-2))
{
n_num = prev + curr;
printf("%d ", n_num);
prev = curr;
curr = n_num;
count++;
}
printf("\n---------------------------------------\n");
return 0;
}
Come again Learn again !
« iCodeBuzz »
No comments:
Post a Comment