Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <cs50.h>
- int main(void)
- {
- int pyramidSteps = 0;
- printf ("Please enter a positive integer no greater than 23: ");
- pyramidSteps = GetInt();
- while (pyramidSteps <= 0 || pyramidSteps >= 23)
- {
- printf ("That is an incorrect integer. Please input an integer in the specified range: ");
- pyramidSteps = GetInt();
- }
- int i = 0;
- for (i = 0; i < pyramidSteps; i++)
- {
- int j = 0;
- for (j = pyramidSteps; j >= 0; j--)
- {
- if (j > i)
- {
- printf (" ");
- }
- if (j <= i)
- {
- printf ("#");
- }
- if (j == 0)
- {
- printf("#\n");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement