Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cs50.h>
- #include <stdio.h>
- int get_positive_int(string prompt) {
- int positive_int;
- do {
- positive_int = get_int("%s",prompt);
- } while (positive_int < 1 || positive_int > 8);
- return positive_int;
- }
- int main(void) {
- int number_of_rows = get_positive_int("Height: ");
- for (int i=0;i<number_of_rows;i++) {
- for (int j=number_of_rows-i-1;j>0;j--) {
- printf(" ");
- }
- for (int k=0;k<i+1;k++) {
- printf("#");
- }
- printf("\n");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement