1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
vodomira [7]
3 years ago
6

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. #include int main(void) {int arrowBaseHeight = 0;int arrowBaseWidth = 0;int arrowHeadWidth = 0;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);printf("\n");// Draw arrow base (height = 3, width = 2)printf( "**\n");printf( "**\n");printf( "**\n");// Draw arrow head (width = 4)printf( "****\n");printf( "***\n");printf( "**\n");printf( "*\n");return 0;}a. Modify the given program to use a loop to output an arrow base of height arrow_base_height. b. Modify the given program to use a loop to output an arrow base of width arrow_base_width.c. Modify the given program to use a loop to output an arrow head of width arrow_head_width.

Computers and Technology
1 answer:
stira [4]3 years ago
8 0

Answer:

Here is the C program:

#include <stdio.h>  //to use input output functions

int main(void) {   //start of main function

 int arrowBaseHeight = 0;  //stores value for arrow base height

int  arrowBaseWidth = 0;  //stores value for arrow base width

 int arrowHeadWidth = 0 ;  //stores value for arrow head width

 int i, j;  //to traverse through the rows and columns

 printf("Enter arrow base height:\n");  //prompts user to enter arrow base height value

 scanf("%d", &arrowBaseHeight);  //reads input value of arrow base height

 printf("Enter arrow base width:\n");  //prompts user to enter arrow base width value

 scanf("%d", &arrowBaseWidth);  //reads input value of arrow base width

 while (arrowHeadWidth <= arrowBaseWidth)  {   //iterates as long as the value of arrowHeadWidth is less than or equals to the value of arrowBaseWidth  

     printf("Enter arrow head width:\n");   //prompts user to enter arrow head width value

     scanf("%d", &arrowHeadWidth);   //reads input value of arrow head width

     printf("\n"); }

 for (i = 0; i < arrowBaseHeight; i++)    {   //iterates through rows

     for (j = 0; j < arrowBaseWidth; j++)  {   //iterates through columns

         printf("*");       }   //prints asterisks

     printf("\n");   }   //prints a new line

 for (i = arrowHeadWidth; i > 0; i--)    {   //loop for input length

     for (j = i; j > 0; j--)        {   //iterates for triangle ( to make arrow head)

         printf("*");       }   //prints asterisks

     printf("\n");   }  } //prints new line

Explanation:

The program asks to enter the height of the arrow base, width of the arrow base and the width of arrow head. When asking to enter the width of the arrow head, a condition is checked that the arrow head width arrowHeadWidth should be less than or equal to width of arrow base arrowBaseWidth. The while loop keeps iterating until the user enters the arrow head width larger than the value of arrow base width.  

The loop is used to output an arrow base of height arrowBaseHeight.

The nested loop is being used which as a whole outputs an arrow base of width arrowBaseWidth. The inner loop draws the stars and forms the base width of the arrow, and the outer loop iterates a number of times equal to the height of the arrow.

The last nested loop is used to output an arrow head of width arrowHeadWidth. The inner loop forms the arrow head and prints the stars needed to form an arrow head.  

The screenshot of output is attached.

You might be interested in
Hich chip contains the information necessary to start the computer system?
Sindrei [870]
The BIOS contains the information.
7 0
3 years ago
What is the value of the totalsString variable after the following code is executed? var totals = [141.95, 212.95, 411, 10.95];
Alex Ar [27]
<h2>Answer:</h2>

141.95|212.95|312.95|10.95|

<h2>Explanation:</h2>

<em>Reformatting the code snippet and giving it line numbers;</em>

1.       var totals = [141.95, 212.95, 411, 10.95];

2.      totals[2] = 312.95;

3.      var totalsString = "";

4.      for (var i = 0; i < totals.length; i++) {

5.          totalsString += totals[i] + "|";

6.      }

Line 1 creates an array called totals with four elements.

     First element = totals[0] =141.95

     Second element = totals[1] = 212.95

     Third element = totals[2] = 411

     Fourth element = totals[3] = 10.95

Line 2 replaces the value of the third element <em>totals[2]</em> = 411 with 312.95.

     Therefore the array <em>totals = </em>[141.95, 212.95, 312.95, 10.95]

Line 3 creates an empty string called totalsString

Lines 4 - 6 create a for loop that cycles from i=0 to i<totals.length

       totals.length = 4 (which is the number of items in the array totals)

       This means that the loop cycles from i=0 to i<4

       During cycle 1 when i = 0, the expression inside the for loop executes as follows;

            totalsString = totalsString + totals[0] + "|"   //substitute the values

            totalsString = "" + 141.95 + "|"

            totalsString = 141.95|

       During cycle 2 when i = 1, the expression inside the for loop executes as follows;

            totalsString = totalsString + totals[1] + "|"   //substitute the values

            totalsString = "141.95|" + 212.95 + "|"

            totalsString = 141.95|212.95|

       During cycle 3 when i = 2, the expression inside the for loop executes as follows;

            totalsString = totalsString + totals[2] + "|"   //substitute the values

            totalsString = "141.95|212.95|" + 312.95 + "|"

            totalsString = 141.95|212.95|312.95|

       During cycle 4 when i = 3, the expression inside the for loop executes as follows;

            totalsString = totalsString + totals[3] + "|"   //substitute the values

            totalsString = "141.95|212.95|312.95|" + 10.95 + "|"

            totalsString = 141.95|212.95|312.95|10.95|

At the end of the execution, totalsString = 141.95|212.95|312.95|10.95|

7 0
3 years ago
What is the difference between above ground mining and underground mining?
neonofarm [45]
If this is in reference to diamond mining then above ground would be panning while below ground would be the actual mining into the soil. 
6 0
3 years ago
Universal containers regularly imports Accounts from an external order system that has its own ID field for each record.What sho
Vikki [24]

Answer:

B. Create a unique External ID field on Accounts in SFDC for matching.                                      

Explanation:

  • External ID is used to prevent duplicate records from being created as a consequence of the import operation, when importing custom objects or person accounts.
  • An external ID is a specific field that contains the External ID attribute.
  • External ID has unique record identifiers from a system that is outside the Salesforce.
  • When this option is selected Data Import Wizard identifies existing Salesforce records with external IDs that match the values in import file.
  • The External ID field enables to keep unique record IDs from an external system, usually for integration.
  • External ID field values should be unique and determine whether or not value are case sensitive can also be determined. For example XYZ and xyz will not be considered same if case sensitive option is not selected.

6 0
3 years ago
grow a sentence frame a small and simple sentence. then expand it. Expand this sentence -I am a gril​
AlekseyPX

Answer:

I am a young lady.

Explanation:

simply sentence or expand more:

  • I am a young lady in my teens. ​
  • I am a young woman in her twenties. ​
  • I am a twenty-year-old lady who is just starting off in life. ​
  • I am a twenty-year-old woman who is just getting her feet wet in the world. ​
6 0
3 years ago
Read 2 more answers
Other questions:
  • Fix the 2 error codes.
    14·1 answer
  • He has a new Wi-Fi router that connects wirelessly to a new desktop and two new laptops, in addition to multiple smartphones, ta
    8·1 answer
  • WILL UPVOTE ALL plz
    13·1 answer
  • What is the difference, if any, between an alpha test group and a beta test group? An alpha test group is made up of people asso
    9·1 answer
  • What is the reason that friction is present in surface to surface contact?
    5·1 answer
  • When an instruction is sent to the CPU in a binary pattern, how does the CPU know what instruction the pattern means
    7·1 answer
  • Which of the following expressions yields an integer between 0 and 100, inclusive? Question 5 options: (int)(Math.random() * 100
    6·1 answer
  • ______design A plan for the actual implementation of the system.
    9·2 answers
  • What type of error occurred with the code below??
    11·1 answer
  • What does this map key show
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!