You are on page 1of 2

/* Program by Thomas Biggs Mario.

c CS50x pset1 Enter the height of the pyramid and then the program displays a graphic representation of it. */

#include<stdio.h> #include<cs50.h> #include<math.h> int main (void) { int ph , s, x, h; do { printf ("Height:"); ph = GetInt(); } while (( ph < 0 ) || ( ph > 23 ));

//variable h is the row of the pyramid, where row 1 is the top and row h is the bottom for (h=1 ; h <= ph ; h++) { printf ("\n"); //spaces are equal to height of the pyramid minus the row number of the pyramid for ( (s = { printf } //x's are equal to for ( (x = { printf } ph-h) ; s > 0 ; s-- ) (" "); the row number of the pyramid h+1) ; x > 0 ; x-- ) ("#");

} return 0;

You might also like