C++ Programming Problem #4 : Fibonacci

Fibonacci sequence is simply by adding up the two numbers before it. The numbers are similarly related to Lucas Numbers which is another mathematical sequence.
Problem #4 : Fibonacci
//---www.skellainnovations.com---//
#include<iostream>
#include<conio.h>
#include<windows.h>
using namespace std;
void gotoxy(int x, int y) {
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
COORD pos;
pos.X = x;
pos.Y = y;
SetConsoleCursorPosition(hConsole,pos); }
int Fibonacci(int num);
main (){
int num=0;
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 160);
gotoxy(23,10);
cout<<" Enter a Number for Fibonacci: ";
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 10);
cout<<" ";
cin>>num;
Fibonacci(num);
gotoxy(25,12);
for(int i=1; i<=num; i++) {
cout << Fibonacci(i) <<" "; }
getch(); }
int Fibonacci(int num){
if (num==1||num==2){
return 1;}
else{
return Fibonacci(num-1) + Fibonacci(num-2);} }
//---www.skellainnovations.com---//
Breakdown of Codes
Additional Components Used
GOTOXY
Fibonacci : GOTOXY
void gotoxy(int x, int y)
{
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
COORD pos;
pos.X = x;
pos.Y = y;
SetConsoleCursorPosition(hConsole,pos);
}
-
This is how to manipulate the location of your text in pixels concept. By using the X and Y coordinates, you have to make sure the right coordinates for your output is in perfect shape.
gotoxy(x,y);
LEGEND : change
-
This is how to change the text attribute color. A specific number corresponds to a specific color.
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), #);
LEGEND : change
Breakdown of Codes : In the Deeper Side of the Process
Integer Function Called
Fibonacci : Integer Function Called
int Fibonacci(int num){
if (num==1||num==2){
return 1;}
else{
return Fibonacci(num-1) + Fibonacci(num-2);}
}

