TRIANGLE

Discussion in 'C++' started by coinjo, Oct 20, 2005.

  1. coinjo

    coinjo Guest

    I need to write a program, which takes two inputs:
    •a value n that represents the number of elements in the
    longest row of a triangle.
    •a character c to be printed in place of each element.
    Your algorithm should produce an isosceles triangle of characters c.
    For example,
    for n=7 and c=’$’, the resulting triangle should be as follows:


    $
    $$$
    $$$$$
    $$$$$$$

    Any hints please? It should only work for odd values of n.
    coinjo, Oct 20, 2005
    #1
    1. Advertising

  2. coinjo wrote:
    > I need to write a program, which takes two inputs:
    > ??a value n that represents the number of elements in the
    > longest row of a triangle.
    > ??a character c to be printed in place of each element.
    > Your algorithm should produce an isosceles triangle of characters c.
    > For example,
    > for n=7 and c='$', the resulting triangle should be as follows:
    >
    >
    > $
    > $$$
    > $$$$$
    > $$$$$$$
    >
    > Any hints please? It should only work for odd values of n.


    You input with

    cin >>

    you output with

    cout <<

    your program should have one function named 'main':

    int main() {
    ...
    }

    V
    Victor Bazarov, Oct 20, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Michael Johnson Jr.
    Replies:
    2
    Views:
    440
    Eric Veltman
    Dec 11, 2003
  2. ad

    No triangle in DropDownList

    ad, Jun 5, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    390
    Eliyahu Goldin
    Jun 5, 2005
  3. henri
    Replies:
    1
    Views:
    376
    Sudsy
    Jun 23, 2004
  4. Diphay Z
    Replies:
    4
    Views:
    401
    =?ISO-8859-1?Q?Daniel_Sj=F6blom?=
    Dec 8, 2004
  5. Replies:
    1
    Views:
    3,384
    Betty
    Apr 11, 2005
Loading...

Share This Page