Users Online

· Guests Online: 137

· Members Online: 0

· Total Members: 188
· Newest Member: meenachowdary055

Forum Threads

Newest Threads
No Threads created
Hottest Threads
No Threads created

Latest Articles

38 C Program to Generate Fibonacci Series

This C Program generates fibonacci series. In fibonacci series the first two numbers in the Fibonacci sequence are 0 and 1 and each subsequent number is the sum of the previous two. For example fibonacci series is 0, 1, 1, 2, 3, 5, 8,13, 21…………
Here is source code of the C program to generate fibonacci series. The C program is successfully compiled and run on a Linux system. The program output is also shown below.

/*
* C program to generate Fibonacci Series. Fibonacci Series
* 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 Series \n");
scanf("%d", &limit);
printf("Fibonacci Series is ...\n");
printf("%d\n", fib1);
printf("%d\n", fib2);
count = 2;
while (count < limit)
{
fib3 = fib1 + fib2;
count++;
printf("%d\n", fib3);
fib1 = fib2;
fib2 = fib3;
}
}

$ cc pgm40.c
$ a.out
Enter the limit to generate the Fibonacci Series
6
Fibonacci Series is ...
0
1
1
2
3
5

Comments

No Comments have been Posted.

Post Comment

Please Login to Post a Comment.

Ratings

Rating is available to Members only.

Please login or register to vote.

No Ratings have been Posted.
Render time: 0.94 seconds
10,807,605 unique visits