Skip to content

Commit

Permalink
Merge pull request #17 from akshaysharma2277/master
Browse files Browse the repository at this point in the history
Fibonacci series in C language
  • Loading branch information
ambujraj authored Oct 1, 2018
2 parents f121aa1 + 1131649 commit 0724b90
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions fibonacci/fibonacci.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include<stdio.h>
int main()
{
int n1=0,n2=1,n3,i,number;
printf("Enter the number of elements:");
scanf("%d",&number);
printf("\n%d %d",n1,n2);//printing 0 and 1
for(i=2;i<number;++i)//loop starts from 2 because 0 and 1 are already printed
{
n3=n1+n2;
printf(" %d",n3);
n1=n2;
n2=n3;
}
return 0;
}

0 comments on commit 0724b90

Please sign in to comment.