Last active
August 29, 2015 14:01
-
-
Save Manume/4f96660d7d46d7460ad2 to your computer and use it in GitHub Desktop.
programs for printing fibonacci series
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream.h> | |
#include <conio.h> | |
void main() | |
{ | |
clrscr(); | |
int a,b,x,y,num1,ct; | |
a=0; | |
b=1; | |
cout << "Enter the number of terms (less than 25) : " << endl; | |
cin>>num1; | |
cout << a << endl; | |
cout << b << endl; | |
for(ct=1;ct<=num1-2;ct++) | |
{ | |
x=a+b; | |
cout << x << endl; | |
y=a; | |
a=b; | |
b=x; | |
} | |
getch(); | |
} | |
sampie input and output | |
input | |
12 | |
output | |
0 | |
1 | |
1 | |
2 | |
3 | |
5 | |
8 | |
13 | |
21 | |
34 | |
55 | |
89 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment