Created
May 20, 2018 16:22
-
-
Save jcoryalvernaz/f98e730e9ed0784b7be15384e9df2c7c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <cs50.h> | |
int main(void) | |
{ | |
//Make variables for height, spaces, and hashes | |
int height; | |
int spaces; | |
int hashes; | |
//Prompt user for height | |
do | |
{ | |
height = get_int("Height: "); | |
} | |
//Set conditions | |
while (height < 0 || height > 23); | |
//Set rows | |
for (int i = 1; i <= height; i++) | |
{ | |
//Set columns of spaces | |
for (spaces = (height - i); spaces > 0; spaces--) | |
{ | |
printf(" "); | |
} | |
//Set columns of hashes | |
for (hashes = 1; hashes <= (i + 1); hashes++) | |
{ | |
printf("#"); | |
} | |
printf("\n"); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment