C program to print fibonacci series i e 0 1 1 2 3 5 8
#include<stdio.h>#include<conio.h>
void main(){ int first=0,second=1,third,i,n; clrscr(); //to clear the screen printf("Enter how many elements?"); scanf("%d",&n); printf("
%d %d",first,second);
for(i=2;i<n;++i) { third=first+second; printf(" %d",third); first=second; second=third; } getch(); //to stop the screen}
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.