Thread: Trapezoids

  1. #1
    Registered User
    Join Date
    Jun 2012
    Posts
    1

    Trapezoids

    Hello, I am a beginner to coding C. I have some rudimentary knowledge on Python. I have an assignment that I should write a function that creates a Trapezoid according to the height and width given. To give an example: enter the height and width of the trapezoid 4 8¶. Then it draws a trapezoid out of # as the outline and the middle as empty space. ¶ to nominate \n. Code must include also an alternative if the given values are too small or negative (2x2 trapezoid is the smallest). Example: enter the height and width of the trapezoid 2 1¶ Invalid input Basically the indentation of the top row is height - 1 and is lowered with each step downwards. What I have so far: #include int main(void){¶ //setting up¶ int x = 0;¶ int y = 0;¶ int indentation = 0;¶ //asking values printf(("enter the height and width of the trapezoid)\n");¶ int height , width;¶ scanf("%d , %d" , &height , &width); ¶ What I now need are loops to print out each individual line. Thinking of doing the actual drawing loop with switch. What I don't yet have is i) disgarding the parameters and putting out the invalid value ii) actual code for the trapezoid to receive the values iii) indentation ought to go with a while loop Trying not to want free candy but it is sweet. Thanks in advance.

  2. #2
    Registered User
    Join Date
    May 2012
    Posts
    1,066
    Quote Originally Posted by Codemonkey92 View Post
    Trying not to want free candy but it is sweet.
    Candy is bad for your young teeth so show us what you have already done.
    And please use Code Tags.

    Bye, Andreas

  3. #3
    Registered User
    Join Date
    Dec 2007
    Posts
    2,675
    I guess this code monkey (or prospective code monkey) wants rotten teeth.

  4. #4
    Registered User
    Join Date
    Jan 2009
    Posts
    1,485
    What's up with the paragraph symbols? Have you copy pasted this from a word document or something?

Popular pages Recent additions subscribe to a feed

Tags for this Thread