4.14 Ch 4 Program: Drawing a half arrow (C++) This program outputs a downwards f
ID: 3698877 • Letter: 4
Question
4.14 Ch 4 Program: Drawing a half arrow (C++) 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 wdth and arrow head w 1) Modity the given program to use a loop to output an arrow base of height arrowBasereight( 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 terates a number of times equal to the height of the arrow base (7 pt) (3) Modify the given program to use a loop to output an arrow head of width Width Use a nested loop in which the inner loop the ourter 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 the user for an arrow head width until the vakue is larger than the arrow base width (1 pe) arger than the arrow base width Use a loop to continue prompting / Prompt user tor a valid arrou head val h - 2, andExplanation / Answer
#include <iostream>
using namespace std;
int main()
{
int arrowBaseHeight = 0;
int arrowBaseWidth = 0;
int arrowHeadWidth = 0;
cout<<"Enter arrow base height: "<<endl;
cin >> arrowBaseHeight;
cout<<"Enter arrow base width: "<<endl;
cin >> arrowBaseWidth;
while (arrowHeadWidth <= arrowBaseWidth) {
cout<<"Enter arrow head width: "<<endl;
cin>>arrowHeadWidth ;
}
// Draw arrow base (height = 3, width = 2)
for(int i=0; i<arrowBaseHeight; i++){
for(int j=0; j<arrowBaseWidth; j++){
cout<<"*";
}
cout<<endl;
}
// Draw arrow head (width = 4)
for(int i=0; i<arrowHeadWidth; i++){
for(int j=0; j<arrowHeadWidth-i; j++){
cout<<"*";
}
cout<<endl;
}
return 0;
}
Output:
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.