Something went wrong. Try again.
My course files for the Online Computer Science degree
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637// Draws a pyramid using recursion
#include <cs50.h>#include <stdio.h>
void draw(int h);
int main(void){ // Get height of pyramid int height = get_int("Height: ");
// Draw pyramid draw(height);}
void draw(int h){ // If nothing to draw if (h == 0) { return; }
// Draw pyramid of height h - 1 draw(h - 1);
// Draw one more row of width h for (int i = 0; i < h; i++) { printf("#"); } printf("\n");}