I'm currently self teaching C++, and have a problem. the purpose of this code is to print asterisks in a pyramiding fashion, with the example being if the input (variable int n) is 5, it should print like this:
*
**
***
****
*****
Here's the code:
#include <iostream>
using namespace std;
int main()
{
int i, n;
cout << "What is your number?" << endl;
cin >> n;
cout << "n is: " << n << endl;
int arr[n];
int z = n;
while(z > 0){
arr[z] = 0;
z--;
}
z = n;
for(int y = 0; y<=z; y++){
arr[y] = z;
cout << "Y is: " << y << endl;
cout << "Arr[Y] is: " << arr[y] << endl;
cout << "z is: " << z << endl;
z--;
}
while(n > 0){
int x = arr[n];
while(x > 0){
cout << "*";
x--;
}
cout << endl;
n--;
}
}
but the first half (rounded up) will always be blank on printing. I don't know how to debug in CodeBlocks yet, so I can't tell you what's hiding in the memory to solve this myself