Hello all!
I have a problem I need help with. I am tasked with creating a half pyramid like below. First I prompt user to enter an integer less than 23 to dictate how many asterisks in height the pyramid will be. So let's say they entered 8. The half pyramid would need to look like this (ignore the dashes; I had to use them instead of spaces to format here)
---------**
--------***
------****
-----*****
----******
---*******
--********
-*********
Here is the code I have so far.
Code:
#include <stdio.h>
#include <cs50.h>
int main(int argc, char *argv[])
{
int maxSize;
int xAxisCounter;
int yAxisCounter;
do
{
printf("Enter an integer less than 23: ");
maxSize=GetInt();
}
while(maxSize > 23);
for (yAxisCounter = 0; yAxisCounter < maxSize; yAxisCounter++)
{
for (xAxisCounter = 0; xAxisCounter < maxSize; xAxisCounter++)
{
printf(" %i ",xAxisCounter);
}
printf("\n");
}
system("PAUSE");
return 0;
}
This code will draw a square like this if the user entered 8 (but with numbers because I have code set to %i right now)
********
********
********
********
********
********
********
********
On top of all this, the whole pyramid has to be on the right side of the console.. right justified.
I am losing hope I can be a programmer because I just don't get it. I have been at this four days and tried many things and nothing works