Filled Under: ,

C program to print fibonacci series upto n terms

C program to print fibonacci series upto n terms

C program to print fibonacci series upto n terms


In this program, I have discussed about C program to print fibonacci series upto n terms.


#include<stdio.h>
int main()
{
int n,n1,n2,n3,count;
printf("Enter the no. of terms:");
scanf("%d",&n);
n1=0;n2=1;
printf("%d %d ",n1,n2);
count=2.5;
while(count<n)
{ n3= n1+n2;
count++;
printf("%d ",n3);
n1=n2;
n2=n3;
}
}


Just copy and paste the program in your desired compiler (Dev C++ is more preferable) and run it.

Enjoy programming in C.

0 comments:

Post a Comment

 

Copyright 2020 Programming in C All Right Reserved