CSSE 120 -- Intro. to Software Development

Homework 22

  1. Make sure you understood all the syntax of the RootTable program. The last 10 slides in today's session, that your instructor skipped or skimmed, will help reinforce the live coding you did in class.
  2. Take a look at the Python vs C comparison document. You may find this helpful as you try to do things in C that you already know how to do in Python.  Feel free to suggest things that we might add to this document.
  3. Also take a look at the Essential C reference document. We didn't require that you buy a book for the C part of the course; this document may help fill the gap.
  4. There is no Angel quiz for the next session.
  5. Complete the 5-minute survey for Tetris, found in Angel at Lessons > Project > Tetris project evaluation of your team and its members.
  6. With your team, agree how you will use your 5 minutes in class during session 23 to show off your extensions.
  7. You must do this assignment using Eclipse and the CNestedLoops project that you checked out from your individual SVN repository in class.

    Be sure to check out that project into your Eclipse C workspace, not your Python workspace. This will require connecting to your repository again in the new workspace, using the SVN Repository Exploring perspective. Recall that your individual SVN repository is at the URL:

    http://svn.cs.rose-hulman.edu/repos/csse120-200820-username

    Within the CNestedLoops project, open the file NestedLoopsPatterns.c. It contains a template for the rest of this assignment.

    The output from most of the functions you are to write is similar (in some cases identical) to output from some of the Python functions that you wrote for Homework 12. So the main purpose of the assignment is to get you accustomed to C syntax.

  8. Look at the function rectangleOfStars. Make sure you understand how it works. Ask for help if you're confused. Note that, unlike Python's print, C's printf does not automatically end the output line or put in extra spaces anywhere.

    Note: You may assume that the functions that print numbers will only be given one-digit numbers as their "highest number to print" actual parameters. Otherwise, some of the output formatting would be very tricky.
  9. (8 points) Based on rectangleOfStars, fill in code for the function triangleOfStars. This prints out a triangle-shaped grid of stars. For example, the code:
    triangleOfStars(6);
    
    should produce the output:
    *
    **
    ***
    ****
    *****
    ******
    

    After testing and debugging this function, commit your work to your Subversion repository. Do this by right-clicking on your CNestedLoops project in Eclipse and choosing Team → Commit.... Be sure to enter in a sensible log message as the course staff will review the messages.

  10. (8 points) The next function, triangleAllNumsEachRow, is like triangleSameNumEachRow, except that each character is its position from the left, instead of from the top. For example:
    triangleAllNumsEachRow(6);
    
    should produce the output:
    1
    12
    123
    1234
    12345
    123456
    

    After testing and debugging this function, commit your work to your Subversion repository using a sensible log message.

  11. (8 points) The next function, triangleNumsCentered, is like triangleNumsRightJustified, except that the triangle is centered and includes spaces. For example:
    triangleNumsCentered(9);
    
    should produce the output:
            1 
           2 2 
          3 3 3 
         4 4 4 4 
        5 5 5 5 5 
       6 6 6 6 6 6 
      7 7 7 7 7 7 7 
     8 8 8 8 8 8 8 8 
    9 9 9 9 9 9 9 9 9 
    

    After testing and debugging this function, commit your work to your Subversion repository using a sensible log message.

  12. Submit your code by committing the final version to your Subversion repository.