C program to generate Fibonacci sequence Fibonacci sequence is 0 1 1 2 3 5 8 13 21 …

by Nideesh C on April 12, 2011 · 0 comments

in C Programming




/* C program to generate Fibonacci sequence Fibonacci sequence is 0 1 1 2 3 5 8 13 21 … */

#include <stdio.h>

void main()
{
int   fib1=0, fib2=1, fib3, limit, count=0;

printf(“Enter the limit to generate the fibonacci sequence\n”);
scanf(“%d”, &limit);

printf(“Fibonacci sequence is …\n”);
printf(“%d\n”,fib1);
printf(“%d\n”,fib2);
count = 2;           /* fib1 and fib2 are already used */

while( count < limit)
{
fib3 = fib1 + fib2;
count ++;
printf(“%d\n”,fib3);
fib1 = fib2;
fib2 = fib3;
}

}             /* End of main() */
/*———————————————————–
Enter the limit to generate the fibonacci sequence
7
Fibonacci sequence is …
0
1
1
2
3
5
8
———————————————————–*/

Not Satisfied ? Just search & get the result

Related Posts Plugin for WordPress, Blogger...
Be Sociable, Share!

Related posts:

  1. C program to generate and print first N FIBONACCI numbers
  2. C program to generate and print prime numbers in a given range. Also print the number of prime numbers
  3. Sample – Program to compute the fibonacci series.
  4. C program to find the number of integers divisible by 5 between the given range N1 and N2, where N1 < N2 and are integers. Also find the sum of all these integer numbers that divisible by 5 and output the computed results
  5. C program to read an English sentence and replace lowercase characters by uppercase and vice-versa. Output the given sentence as well as the case converted sentence on two different lines.

Leave a Comment

Previous post:

Next post: