#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Posts
    4
    Rep Power
    0

    Angry please help me!!


    Please help me..

    I have to create a program that will input a number and then print them in a triangle pattern. Eg: If the number 5 was inputted then the output would be:
    1
    22
    333
    4444
    55555

    I got the program half working. It prints the first column of numbers but that is it. I know i have to use a for loop but i have no idea how. The program so far is as follows:

    #include <stdio.h>

    int main(void)
    {

    int number;
    int count = 1;

    printf("Please enter the number:\n");
    scanf("%d", &number);
    printf(" \n");


    do
    {
    printf("%d\n", count);
    count = count + 1;

    }
    while ( count < number );

    }

    Thanks
  2. #2
  3. /(bb|[^b]{2})/

    Join Date
    Nov 2001
    Location
    Somewhere in the great unknown
    Posts
    5,163
    Rep Power
    793
    Two things:
    1) Your subject title is unacceptable. You can refer to the sticky thread at the top of this forum for more information on how to post a question.

    2) Do not post questions to help solve homework problems. Go to your instuctor and/or peers for help on homework.
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Posts
    4
    Rep Power
    0
    Joe,

    1). Regarding the subject line, I didn't know there was a format on the posts.

    2). I am not posting questions to take an easy way out of solving "homework" problems, i have exhausted all other means of solving this problem and hence is why i made a post.

    3). Time is very limited when it comes to asking instructors for help regarding all questions

    4). I would not have made a post asking strangers for help if one of my friends could have helped me.

    Ashkan
  6. #4
  7. /(bb|[^b]{2})/

    Join Date
    Nov 2001
    Location
    Somewhere in the great unknown
    Posts
    5,163
    Rep Power
    793
    Your format is the reason why I stated that you need to read the stick thread at the top of this forum. It gives you the info that you need to know.

    Comming here asking for help on homework will always get you trouble in these forums because it is highly discouraged.

    This is more for your protection then anything else. Most of the code that could be written for this would not look like a beginners program and is typically apparant to instructors. To get you started though try following this logic:

    - get a number from the user (c (fgets/scanf) c++ (cin))
    - loop this number of times (for () )
    -- loop to display a line (for () )
    --- build a line
    --- next inner loop
    -- display the built line
    - next outer loop
  8. #5
  9. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Posts
    4
    Rep Power
    0
    Thank you sincerely Joe, with the help you gave me I got the program working

    Many thanks,
    Ashkan

IMN logo majestic logo threadwatch logo seochat tools logo