Question

In: Computer Science

Solve in C language This program outputs a downwards facing arrow composed of a rectangle and...

Solve in C language

This program outputs a downwards facing arrow composed of a rectangle and a right triangle. The arrow dimensions are defined by user specified arrow base height, arrow base width, and arrow head width.

(1) Modify the given program to use a loop to output an arrow base of height arrowBaseHeight. (1 pt)

(2) Modify the given program to use a loop to output an arrow base of width arrowBaseWidth. Use a nested loop in which the inner loop draws the *’s, and the outer loop iterates a number of times equal to the height of the arrow base. (1 pt)

(3) Modify the given program to use a loop to output an arrow head of width arrowHeadWidth. Use a nested loop in which the inner loop draws the *’s, and the outer loop iterates a number of times equal to the height of the arrow head. (2 pts)

(4) Modify the given program to only accept an arrow head width that is larger than the arrow base width. Use a loop to continue prompting the user for an arrow head width until the value is larger than the arrow base width. (1 pt)

while (arrowHeadWidth <= arrowBaseWidth) {
    // Prompt user for a valid arrow head value
}

Example output for arrowBaseHeight = 5, arrowBaseWidth = 2, and arrowHeadWidth = 4:

Enter arrow base height:
5
Enter arrow base width:
2
Enter arrow head width:
4

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

Solutions

Expert Solution

#include <stdio.h>

int main() {
    int i, j, arrowBaseHeight, arrowBaseWidth, arrowHeadWidth;

    printf("Enter arrow base height:\n");
    scanf("%d", &arrowBaseHeight);

    printf("Enter arrow base width:\n");
    scanf("%d", &arrowBaseWidth);

    printf("Enter arrow head width:\n");
    scanf("%d", &arrowHeadWidth);
    while (arrowHeadWidth <= arrowBaseWidth) {
        printf("Enter arrow head width:\n");
        scanf("%d", &arrowHeadWidth);
    }

    printf("\n");
    for (i = 0; i < arrowBaseHeight; i++) {
        for (j = 0; j < arrowBaseWidth; j++) {
            printf("*");
        }
        printf("\n");
    }

    for (i = arrowHeadWidth; i > 0; i--) {
        for (j = 0; j < i; j++) {
            printf("*");
        }
        printf("\n");
    }
    return 0;
}


Related Solutions

Program: Drawing a half arrow This program outputs a downwards facing arrow composed of a rectangle...
Program: Drawing a half arrow This program outputs a downwards facing arrow composed of a rectangle and a right triangle. The arrow dimensions are defined by user specified arrow base height, arrow base width, and arrow head width. (1) Modify the given program to use a loop to output an arrow base of height arrowBaseHeight. (1 pt) (2) Modify the given program to use a loop to output an arrow base of width arrowBaseWidth. Use a nested loop in which...
4.24 LAB*: Program: Drawing a half arrow This program outputs a downwards facing arrow composed of...
4.24 LAB*: Program: Drawing a half arrow This program outputs a downwards facing arrow composed of a rectangle and a right triangle. The arrow dimensions are defined by user specified arrow base height, arrow base width, and arrow head width. (1) Modify the given program to use a loop to output an arrow base of height arrowBaseHeight. (1 pt) (2) Modify the given program to use a loop to output an arrow base of width arrowBaseWidth. Use a nested loop...
Write a program 'Rectangle-Area.c' that inputs the length and width of a rectangle and outputs its...
Write a program 'Rectangle-Area.c' that inputs the length and width of a rectangle and outputs its area. The program consists of two functions: the main function and a function that computes and returns the area of a rectangle. The output of the program should be in the main program, not in the function.      Sample Input: 5 8   Sample Output: The area of a 5 by 8 rectangle is 40.
IN C++ LANGUAGE PLEASE::: Design and implement a program (name it Rectangle) to calculate and display...
IN C++ LANGUAGE PLEASE::: Design and implement a program (name it Rectangle) to calculate and display the area and perimeter of a rectangle with width = 4 and height = 8.
(LANGUAGE C++) This time, you will finish the program so that the user gets to solve...
(LANGUAGE C++) This time, you will finish the program so that the user gets to solve the puzzle. You will also use header files and introduce classes into your program. We will follow the draft start to how to incorporate classes. Here are the requirements: ·In the file quotes.h, define the Quotes class: o   Quotes(string filename) // a constructor to load quotes from the named file into a vector o   The vector should be a field of the class so it will...
Write a simple shell in C language and show some outputs.
Write a simple shell in C language and show some outputs.
Assembly language program create a program that outputs a picture that represents halloween in ASCll art...
Assembly language program create a program that outputs a picture that represents halloween in ASCll art (jack-o-lantern, witch's hat, etc)
Write a program in assembly language that outputs the leap years between a beginning and an...
Write a program in assembly language that outputs the leap years between a beginning and an ending year. 1. Initialize $a0 and $a1 with the beginning and ending years. 2. Print out the leap years between 1970 and 2030. OUTPUT: From 1970 to 2030: 1972 … 2028
Write the simple shell in C language. Please show some outputs.
Write the simple shell in C language. Please show some outputs.
Solve this question in C++ language. DO NOT use loops. Use recursive function. Keep the program...
Solve this question in C++ language. DO NOT use loops. Use recursive function. Keep the program simple. Q (5) Suppose you have been given the task to design a text editor which will take any multiline text from user and then display the statistics like total number of characters i.e., characters_count (excluding the white space and punctuations), words_count, and redundant_words_count. Create a structure named Text_Editor having four type members namely inserted_text (of type string), characters_count (of type unsigned int), words_count...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT