added ws202425 courses
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
// Draws a pyramid using iteration
|
||||
|
||||
#include <cs50.h>
|
||||
#include <stdio.h>
|
||||
|
||||
void draw(int n);
|
||||
|
||||
int main(void)
|
||||
{
|
||||
// Get height of pyramid
|
||||
int height = get_int("Height: ");
|
||||
|
||||
// Draw pyramid
|
||||
draw(height);
|
||||
}
|
||||
|
||||
void draw(int n)
|
||||
{
|
||||
// Draw pyramid of height n
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
for (int j = 0; j < i + 1; j++)
|
||||
{
|
||||
printf("#");
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user