Results 1 to 4 of 4

Thread: Triangle generator

  1. #1
    gelsys1208 Guest

    angry Triangle generator

    I have to ask the user for a size (an integer), and output a triangle of that many rows as follows:

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

    p.s. note that the triangle is displayed from left to right. this triangle has 2 be displayed from right to left. thanks!

  2. #2
    Join Date
    Jan 2009
    Posts
    1,738

    Re: Triangle generator

    Which language you want to do it in? Atleast mention that...

  3. #3
    gelsys1208 Guest

    ThumbsUp Re: Triangle generator

    Quote Originally Posted by Rudra.J View Post
    Which language you want to do it in? Atleast mention that...
    Hey im sorry i know i should have mentioned that, 1 word: OOPS!
    anyway thanks....i got it working!

  4. #4
    Join Date
    Oct 2010
    Posts
    1

    Re: Triangle generator

    I am new to C++ but I thought I might try just giving this a shot. So there might be better ways of doing this but it seems to work.

    #include <iostream>
    using namespace std;

    int main ()
    {
    short int numRows;
    cout << "How many rows do you want your triangle?\n";
    cin >> numRows;
    cout << "\n";

    for (int row = 1; row <= numRows; row++)
    {

    for (int col1 = 0; col1 < numRows - row; col1++)
    {

    cout << " ";

    }

    for (int col2 = 0; col2 < row; col2++)
    {

    cout << "*";

    }

    cout << "\n";

    }

    return 0;
    }

Similar Threads

  1. utorrent yellow triangle indicator
    By Rily in forum Windows Software
    Replies: 3
    Last Post: 24-06-2010, 03:44 PM
  2. What is the Code for Floyd's triangle in C ??
    By Silent~Kid in forum Software Development
    Replies: 5
    Last Post: 02-01-2010, 07:43 PM
  3. Triangle using C++
    By Brake Fail in forum Software Development
    Replies: 4
    Last Post: 04-02-2009, 11:54 PM
  4. Want To Print Triangle In C++
    By vishodhan in forum Software Development
    Replies: 1
    Last Post: 08-01-2009, 09:53 PM
  5. Yellow triangle in the taskbar
    By harakim in forum Windows Software
    Replies: 3
    Last Post: 03-10-2008, 03:09 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,711,689,316.39979 seconds with 17 queries