Thread: coding a triangle

  1. #1
    Registered User
    Join Date
    Sep 2001
    Posts
    2

    Exclamation coding a triangle

    I was wondering if anyone could help me code a triangle that generates the following output:

    1
    1 2 3
    1 2 3 4 5
    1 2 3 4 5 6 7
    1 2 3 4 5 6 7 8 9

  2. #2
    Frustrated Programmer :( phantom's Avatar
    Join Date
    Sep 2001
    Posts
    163
    try

    int max; //Max is the highest number you wish to goto

    for (int i =1; i <= max; i++)
    {
    for(int j = 0; j <= i; j++)
    {
    cout<<j<<" ";
    }
    cout<<endl;
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Recursive Triangle Function
    By w2look in forum C Programming
    Replies: 14
    Last Post: 11-13-2010, 02:31 PM
  2. Right Triangle Program
    By BSmith4740 in forum C# Programming
    Replies: 9
    Last Post: 02-27-2008, 12:24 AM
  3. Resizing a triangle. Why is my code not working?
    By gozu in forum Windows Programming
    Replies: 2
    Last Post: 01-20-2007, 06:40 PM
  4. Just in case: "Odd" Triangle Challenge (for me)
    By BB18 in forum C Programming
    Replies: 3
    Last Post: 10-09-2004, 12:02 AM
  5. Determining a Triangle using get and pointer
    By naynay in forum C Programming
    Replies: 7
    Last Post: 04-11-2003, 05:55 AM