Fibonacci numbers program in C Language
Write a Fibonacci numbers program in C program in C to generate first 20 Fibonacci numbers using simple Code. User needs to enter till which number Fibonacci numbers should be printed through user Interface.
After getting the right input program will print the Fibonacci numbers .
The first 21 Fibonacci numbers Fn for n = 0, 1, 2, …, 20.By definition of Fibonacci numbers, it starts with first two numbers in the Fibonacci sequence as 0 and 1, and each subsequent number is the sum of the previous two.
like 0,1,1,2………
Fibonacci numbers program in C Code
#include<stdio.h> #include<conio.h> void main() { int a,b,c,num,i; a=0,b=1,c=0; clrscr(); printf(“\nEnter the number till which u want the series::”); scanf(“%d”,&num); printf(“\n”); for(i=0;i<num;i++,c=a+b) { a=b; b=c; printf(“%d\t”,c); } getch(); }
Leave a Reply