[SOLVED] CS214 Assignment 1-Returned

35.00 $

Category:
Click Category Button to View Your Next Assignment | Homework

You will receive the following solution file(s) instantly after successful payment:

zip file icon Assignment-1-iehumx.zip (319.5 KB)
Assignment Instructions Updated Recently? Submit Below and we will provide new Solution!
Submit New Instructions
🔒 Securely Powered by:
Secure Checkout
Rate this product

 

1. Create a C source le and copy the following function denition into it:

void triangle(unsigned width)
{
    unsigned i, j;
    i = 0;
    while (i <= width) {
        j = 0;
        while (j < i) {
            putchar('*');

++j; }

        putchar('\n');

++i; }

}

Add a main function that calls triangle() with a number of your choosing, and complete the source le such that you can compile and execute your program.

2.  Rewrite triangle() to use for loops instead of while loops.

3.  Write a version of triangle() called v_triangle() that prints the triangle upside-down, with the maximum length line at the top.

https://sakai.rutgers.edu/portal/site/f55b6385-2252-4de5-a0e1-6b8fe3227eeb/tool/5b736e6b-8b6b-4963-af7f-8ab2a622a40c?panel=Main 1/2

1/24/22, 2:39 PM sakai.rutgers.edu : CS 214 — Spring 2021 : Assignments

4. Write a version of triangle() called h_triangle() that prints the triangle such that the right side is vertical. That is, h_triangle(5) should print

*****
 ****
  ***
   **
    *

5. (3 points) Create a program that can print any of the three triangles described above, based on its command-line arguments. Use atoi() to convert the rst argument from a string to an integer: this will be the width of the triangle. If no second argument is provided, use triangle(). If the second argument is “v”, use v_triangle(). If it is “h”, use h_triangle().

Your program should return EXIT_SUCCESS from main for normal operation, or EXIT_FAILURE if given incorrect/inappropriate arguments.

Submit your code for question 5, or as much of it as you can complete.

Submitted Attachments

triangle.c ( 2 KB; Feb 9, 2021 11:24 pm )

Additional instructor’s comments about your submission

 

  • Assignment-1-iehumx.zip