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]
2 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]2 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
Complete the implementation of the following methods:__init__hasNext()next()getFirstToken()getNextToken()nextChar()skipWhiteSpac
andrey2020 [161]

From method names, I am compelled to believe you are creating some sort of a Lexer object. Generally you implement Lexer with stratified design. First consumption of characters, then tokens (made out of characters), then optionally constructs made out of tokens.

Hope this helps.

6 0
2 years ago
The first computer introduced was the IBM PC. A. True B. False
Lerok [7]
The answer to your question is true
5 0
3 years ago
Read 2 more answers
Marco had a database that showed the first, second, and third favorite ice cream flavors for each person in his school. He used
Maksim231197 [3]

Answer:

B

turned data into information

7 0
2 years ago
Read 2 more answers
Write a 20 charecter poem! for points! :)
umka21 [38]
The sky was blue
Glistening clouds in the air
For the little boy had no clue
His mother sat him down on the warm chair

There’s some great news
Hitler took over
And they killed off the Jews
The little boy just wanted to show mom his 4 leaf clover
7 0
2 years ago
Read 2 more answers
Care should be taken whenever you post comments or photos to any social media or other websites, because each of these online ac
ohaa [14]

Answer:

True is the correct answer for the above question.

Explanation:

  • The social website is used to connect the people using the internet to communicate. With the help of this, any people can communicate within the world's people.
  • If anyone posts their pictures or comment on this type of website, then they need to care for that post or pictures. it means he needs to make decisions to choose the pictures or comments while posting.
  • It is because when the user posts the wrong comments or pictures, then their popularity is less in front of the other people called society.
  • This concept is also said by the question, hence it is a true statement.
5 0
3 years ago
Other questions:
  • Dial-up connections can be made over a(n) ____ line or phone line. isdn dsl ipx tcp/ip
    12·1 answer
  • When one block is executed after another block in order from top to bottom, this is called ______ (see picture) Question 31 opti
    8·1 answer
  • The house had a wonderful pool of ... (his/its/our) own.​
    5·1 answer
  • Put the steps of the decision-making process in the correct order.
    12·1 answer
  • Are to print or find<br> the sum<br> 5 numbers<br> of<br> using flow chart
    6·1 answer
  • Which type of image format is constructed using proportional formulas rather than pixels? This task contains the radio buttons a
    12·2 answers
  • Write a program that uses an initializer list to store the following set of numbers in an array named nums. Then, print the arra
    10·2 answers
  • What was the name of the first personal computer and what year was it introduced
    7·1 answer
  • What is one of the advantages of using an algorithm to solve a puzzle like Kriss-Kross or Sudoku?
    13·1 answer
  • If you want to change the name of a folder that stores Word documents, what should you do before changing the
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!