-
-
Save bANNji/9648326 to your computer and use it in GitHub Desktop.
Tada
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 <cs50.h> | |
#include <stdio.h> | |
int main(void) | |
{ | |
int currentHeight = 0; | |
int requestedHeight = 0; | |
bool exit = false; | |
do | |
{ | |
printf("Enter a desired height: "); | |
requestedHeight = GetInt(); | |
if((requestedHeight <= 0) || (requestedHeight > 23)) | |
{ | |
printf("Invalid Entry, Please enter int between 1 - 23\n"); | |
} | |
else | |
{ | |
exit = true; | |
} | |
} | |
while ((requestedHeight <= 0) || (requestedHeight > 23)); | |
while(currentHeight < requestedHeight) | |
{ | |
for (int spaceBw = 0; spaceBw < requestedHeight - currentHeight; spaceBw++) | |
{ | |
printf(" "); | |
} | |
for (int hashBw = 0; hashBw < (2 + currentHeight); hashBw++) | |
{ | |
printf("#"); | |
} | |
for (int gap = 0; gap < 2; gap++) | |
{ | |
printf(" "); | |
} | |
for (int hashFw = 0; hashFw < (2 + currentHeight); hashFw++) | |
{ | |
printf("#"); | |
} | |
for (int nextLine = 0; nextLine < 1; nextLine++) | |
{ | |
printf("\n"); | |
currentHeight++; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment