Last active
August 29, 2015 14:06
-
-
Save ruhi1999/922d85309821fd45fbca to your computer and use it in GitHub Desktop.
right-aligns hashtag pyramid given height; does not accept over 23
This file contains hidden or 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) | |
| { | |
| int n,i,j,k; | |
| do | |
| { | |
| printf("Height:"); | |
| n=GetInt(); | |
| } | |
| while (n>23 || n<0); | |
| int hashes=2; | |
| int spaces=n-1; | |
| for (i=0; i < n; i++) | |
| { | |
| for (j=0; j<spaces; j++) | |
| { | |
| printf(" "); | |
| } | |
| for (k=0; k<hashes; k++) | |
| { | |
| printf("#"); | |
| } | |
| hashes++; | |
| spaces--; | |
| printf("\n"); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment