Some quick help please!

This is a discussion on Some quick help please! within the C Programming forums, part of the General Programming Boards category; Hey I need some quick help with this problem. Im new to this stuff and need some help with this. ...

  1. #1
    Registered User
    Join Date
    Sep 2003
    Posts
    56

    Some quick help please!

    Hey I need some quick help with this problem. Im new to this stuff and need some help with this. This is my sample problem that is spose to be easy. I just need some help with this before i do the main project. Can someone please help me with this real quick so i have a main idea on what needs to be done for the rest of the project? Thanx for all of your guys help. Once i get the hang of this stuff ill soon be able to help you guys out.
    anyway, heres the problem....

    Given the length, L, and height, H, of a parallelogram, entered from the user, draw a representation of the parallelogram using stars. For example, a parallelgram of length 5 and width 4 can be represented as follows:

    *****
    .*****
    ..*****
    ...*****

    the dots are spaces "." the object is slanted

    In particular, the first row of the design contains L stars starting from the left-most column. Each subsequent row starts with one more space than the previous row followed by L stars. A total of H rows will be printed.

  2. #2
    Registered User
    Join Date
    Oct 2003
    Posts
    49
    Use for loops for that.

    Code:
    int i,j;
    
    for(i=0; i<H; i++) {
       for(j=0; j<i; j++) printf(" ");
       for(j=0; j<L; j++) printf("*");
       printf("\n");
    }

  3. #3
    Registered User
    Join Date
    Sep 2003
    Posts
    56

    is that it?

    Is that the entire program??

  4. #4
    Registered User
    Join Date
    Oct 2003
    Posts
    49
    It's nearly the entire program.
    You really should be able to do the rest.

  5. #5
    Registered User
    Join Date
    Sep 2003
    Posts
    56

    what next?

    NOw all i have to do is ask the user for the inputs?

  6. #6
    Registered User
    Join Date
    Oct 2003
    Posts
    49
    Code:
    #include <stdio.h>
    
    int main()
    {
       int i,j,h,l;
    
       printf("\nInput height: ");
       scanf("%d",&h);
       printf("Input length: ");
       scanf("%d",&l);
       for(i=0; i<h; i++) {
          for(j=0; j<i; j++) printf(" ");
          for(j=0; j<l; j++) printf("*");
          printf("\n");
       }
    return 0;
    }

  7. #7
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,006
    >NOw all i have to do is ask the user for the inputs?

    FAQ > How do I... (Level 1) > How do I get a number from the user (C)
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  8. #8
    Registered User
    Join Date
    Sep 2003
    Posts
    56

    Thank you so much

    Thanks guys for all your help, im sure ill have more questions in the future. i hope youll help me then. thanks

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. strcmp returning 1...
    By Axel in forum C Programming
    Replies: 12
    Last Post: 09-08-2006, 07:48 PM
  2. Do you know...
    By davejigsaw in forum C++ Programming
    Replies: 1
    Last Post: 05-10-2005, 10:33 AM
  3. Questions on basic Quick Sort
    By Weng in forum C++ Programming
    Replies: 4
    Last Post: 12-16-2003, 09:06 AM
  4. Quick Sort Help
    By NavyBlue in forum C Programming
    Replies: 1
    Last Post: 03-02-2003, 09:34 PM
  5. Replies: 0
    Last Post: 04-30-2002, 07:24 PM

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