My program should prints a sequence of 20 fibonacci numbers in a simple way
As u all know the f(n) of fibonacci numbers is as follows:
0 if n=0
1 if n=1
fn-1 + fn+1 if n>1
I made the code and there's no errors , but it gives me nothing !!!
Can anyone tell me what's wrong with my code ?
#include <iostream>
using namespace std;
int main () {
cout<<" --»(( W E L C O M E ))«-- \n\n\n"<<endl;
cout<<" This program shows a series of fibonacci numbers \n\n\n"<<endl;
cout<<"-------------------------------"<<endl;
int n=0;
int fnum;
int counter=-1;
while (n<=20) {
if (n==1){
fnum=1;
counter=counter+1;
}
while (n>1){
fnum=(n-1)+(n+1);
counter=counter+1;
}
}
cout<<fnum<<endl;
if (n==0){
fnum=0;
counter=counter+1;
}
return 0;
}

New Topic/Question
Reply




MultiQuote







|