Skip to content

Instantly share code, notes, and snippets.

@bANNji
Created March 19, 2014 18:38
Show Gist options
  • Save bANNji/9648326 to your computer and use it in GitHub Desktop.
Save bANNji/9648326 to your computer and use it in GitHub Desktop.
Tada
#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