C program to find fibonacci series.|c |languagecopy.blogspot.

Question:

Write a Program in C to take input from user and find the fibonacci series of number.

Source Code:

#include<stdio.h> void fib(int num1) { if(num1==0) { printf("0"); } else if(num1==1) { printf("0 , 1"); } else { int term1=0,term2=1; int i,next; for(i=0;i<num1;++i) { printf("%d, ", term1); next= term1 + term2; term1 = term2; term2 = next; } } } int main() { int num; printf("Enter the number to find the fibonacci series\n"); scanf("%d",&num); printf("fibonacci series:\n"); fib(num); return 0; }

Output:

Enter the number to find the fibonacci series 5 fibonacci series: 0,1,1,2,3,

Comments

Popular posts from this blog

Introduction to Python.

Decision Making Statement.