Puzzle L36


Print centered triangle

[E-5]Write a function that prints a centered triangle created by printed several centered rows of a specified character. The parameters to the function are the number of rows and the character to print. Use center() .

    *
   ***
  *****
 *******
*********

Each row of the triangle has an odd number of characters.

#include <stdio.h>

void center(char ch, int count, int length)
{
}

void triangle(char ch, int rows)
{
}

int main()
{
  triangle('*', 5);  
  return 0;
}


Previous Page        Answer         Next Page         Home