How can I make the output print out to the screen in reverse?
Code:#include <iostream>
#include <iomanip>
using namespace std;
int getnum();
void Fibonacci(int n);
int main ()
{
int n;
cout << "\n\t +======================================================+\n";
cout << "\t |======== ========|\n";
cout << "\t |===== =====|\n";
cout << "\t |=== Fibonacci Sequence Generator ===|\n";
cout << "\t |==== ====|\n";
cout << "\t |======= =======|\n";
cout << "\t +======================================================+\n\n\n\n";
n = getnum();
Fibonacci(n);
cout << "\n";
return 0;
}
/*********************************************FUNCTIONS*************************************************/
int getnum()
{
int n = 0;
do{
cout << "\n +---------------------------------------------------------------------+\n";
cout << " | How many numbers of the FIBONACCI SEQUENCE do you want dislayed?? |\n";
cout << " +---------------------------------------------------------------------+\n\n\t\t\t\t :";
cin >> n;
if(n <= 0)
{
cout << "\n\t\t !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n";
cout << "\t\t !!!!!! !!!!!!\n";
cout << "\t\t !!!! Does Not Compute!! !!!!\n";
cout << "\t\t !!!!!! !!!!!!\n";
cout << "\t\t !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n";
}
cout << '\n';
}while(n <= 0);
return n;
}
void Fibonacci(int n)
{
int i;
int x = 0, y = 1;
int sum;
const int MaxPerLine = 6;
int count = 0;
cout << "\n\t *******************************************************\n";
cout << "\t The first " << n << " integers of the Fibonacci series are: \n";
cout << "\t *******************************************************\n\n";
for (i = 0; i < n; ++i)
{
if(i <= 1)
{
sum = i;
}
cout << setw(5) << x;
sum = x + y; //sums x and y at ever increment
x = y; //changes variable value in preperation for the next calculation
y = sum; //changes variable value in preperation for the next calculation
++count;
if(count % 6 == 0) //condition that inputs a new line after every 6 values
{
cout << '\n';
}
}
}