Fibonocii series :-
Fibonacci series mean . . . First Program will print tow numbers {1,1} then program will add previous two numbers and print it on next index For example {1,1,2,3,5,8,13,21, . . . }
Source code of Fibonacci (C++)is available here
#include "stdafx.h" // Header file for MS VS
#include <iostream> // Some compiler used < iostream.h>
#include <conio.h> // header file
using namespace std ;
int main ()
{
int max ;
int num = 1 ;
int num2 = 1 ;
cout << "Enter Maximum No . : " ;
cin >> max ;
cout << num << " " ;
while (num <= max)
{
cout << num << " " ;
int i = num ;
num = num + num2 ;
num2 = i ;
}
_getch() ; // some compiler uses getch()
return 0 ;
}
Fibonacci series mean . . . First Program will print tow numbers {1,1} then program will add previous two numbers and print it on next index For example {1,1,2,3,5,8,13,21, . . . }
Source code of Fibonacci (C++)is available here
#include "stdafx.h" // Header file for MS VS
#include <iostream> // Some compiler used < iostream.h>
#include <conio.h> // header file
using namespace std ;
int main ()
{
int max ;
int num = 1 ;
int num2 = 1 ;
cout << "Enter Maximum No . : " ;
cin >> max ;
cout << num << " " ;
while (num <= max)
{
cout << num << " " ;
int i = num ;
num = num + num2 ;
num2 = i ;
}
_getch() ; // some compiler uses getch()
return 0 ;
}
0 comments:
Post a Comment