Fibonacci Sequence using C

Fibonacci Sequence using C

This program will produce an inputted number of terms of the Fibonacci Sequence using C Programming Language


int main() { 
int count, first_num = 0, second_num = 1, next_num, i;
printf("Enter the number of terms:\n"); scanf("%d",&count); 
printf("First %d terms of Fibonacci series:\n",count); 
for ( i = 0 ; i < count ; i++ ) { 
if ( i <= 1 ) next_num = i; 
else { next_num = first_num + second_num; first_num = second_num; second_num = next_num; } 
printf("%d\n",next_num); } 
return 0; }

Share with Friends

Twitter Facebook Google LinkedIn Email Pinterest Reddit StumbleUpon Tumblr

Try these Fun Games by Bobbie:

Travel Blast Game New York

Play and Learn Russian

Battlestarship Game

Take a look at these Groovy Codes:

Fun IQ Test

Html Svg Starburst

Javascript Particles Fishes

Read the Latest Breaking Programming and Tech News, Great Articles and Tips:

Codenewz Programming and Tech News


Post a Comment

Popular posts from this blog

Multi-tap Keypad Text Entry

Free Code Examples Directory