CS 200 - Lab 17

Draw a cone

Write a program to draw a cone.  Example run (user input in bold red):

Height of cone? 6
*
***
*****
*******
*********
***********

Use two functions in your program:

  1. print_spaces: draw the leading spaces on each line
  2. print_stars: draw the row of * characters on each line

Both of these functions have a void return type, because they do not compute a value.  Instead, they are used for side-effect: printing output using printf.

Getting Started

If you have a solution open in Visual Studio, close it (File->Close Solution).

Download lab17.zip.  Import it into Visual Studio (File->Import...).

Add your code to the source file called Cone.c.

Hints

In your main function, use a loop to print each row of the figure.  Each row consists of a number of spaces and a number of stars.  Within the loop body, call each of the two functions you have implemented to print the appropriate number of each character.