Puzzle L37


Print centered truncated triangle

[E-5]Write a function that prints a centered triangle with a base of N characters and a top row of T characters. The triangle is centered in a row of length number of characters (although trailing blanks are not printed.)

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

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

#include <stdio.h>

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

void truncTriangle(char ch, int base, int top, int length)
{
}

int main()
{
  truncTriangle('*', 9, 3, 17);  
  return 0;
}


Previous Page        Answer         Next Page         Home