simplest coding "for" using i

This is a discussion on simplest coding "for" using i within the C Programming forums, part of the General Programming Boards category; Could anyone help me with the simplest way of coding a triangle.. starting with a 1, and a 123 underneath ...

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

    Question simplest coding "for" using i

    Could anyone help me with the simplest way of coding a triangle..
    starting with a 1, and a 123 underneath that and a 12345 underneath that and 1234567 "" "" and then ending with 123456789 underneath that..

  2. #2
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    Do you want a triangle like:
    Code:
    1
    123
    12345
    1234567
    123456789
    or

    Code:
        1
       123
      12345
     1234567
    123456789
    For the first one try this:

    Code:
    main()
    {
    int i,c;
    
    for(i=1;i<=9;i+=2)
       {
       for(c=1;c<=i;c++)
          {      
          printf("%d",c);
          }
        printf("\n");
        }
    
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 9
    Last Post: 03-20-2009, 05:22 PM
  2. Coding Guideline ....!!
    By imfeelingfortun in forum Tech Board
    Replies: 8
    Last Post: 10-08-2006, 07:09 AM
  3. Before Coding
    By cyberCLoWn in forum C++ Programming
    Replies: 16
    Last Post: 12-15-2003, 01:26 AM
  4. Coding Contest....
    By Koshare in forum A Brief History of Cprogramming.com
    Replies: 46
    Last Post: 10-14-2001, 04:32 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21