I am trying to make this:
( I cant really draw it correctly here it wont let me but it should be 2 pyramids one on top of the other.)
Code:
*
* *
* * *
* * * *
* * *
* *
*
The Largest row that is the middle row's length will be determined by the user. I have been trying and trying but its proving to be really hard for me. Here is the code I have so far it is not complete and my results are not what I want.
The pyramids have to be made using recursive functions.
Code:
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
int printTopStars(int num);
int printBottomStars(int num);
int main()
{
int num;
cout << " Enter the number of stars in the largest row of the pyramid: " << endl;
cin >> num;
printTopStars(num);
return 0;
}
int printTopStars(int num)
{
int counter = 0;
if(num == 0)
return 0;
else
for(counter;counter < num; counter++)
{
cout << "*";
}
cout << endl;
return printTopStars(num -1);
}
int printBottomStars(int num)
{
return 0;
}
The outcome of my program as of now is this:
******
*****
****
***
**
*
Any advice would be greatly appreciated.
-Mike