-
-
Save sameekapdi/b92ff2dd87b9736be37a02bf8805125d 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 <cs50.h> | |
#include <stdio.h> | |
int main(void) | |
{ | |
int height; | |
do | |
{ | |
printf("Height: "); | |
height = get_int(); | |
} while (height < 0 || height > 23); | |
for (int i = 0; i < height; i++) | |
{ | |
//print spaces for left pyramid | |
for (int c = 2; c <= height - i; c++) | |
{ | |
printf(" "); | |
} | |
//print hashes for left pyramid | |
for (int c = 0; c <=i; c++) | |
{ | |
printf("#"); | |
} | |
//print gap | |
printf(" "); | |
//print right hashes | |
for (int c = 0; c <=i; c++) | |
{ | |
printf("#"); | |
} | |
//print new line | |
printf("\n"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment