Write a program that outputs a downwards facing arrow composed of a rectangle and a right triangle. Arrow dimensions are defined by user specified arrow base height, arrow base width, and arrow head width. Input the arrow base height (int) and width (int). Draw a rectangle using asterisks (height x width). Hint: use a nested loop in which the inner loop draws one row of *s, and the outer loop iterates a number of times equal to the height. Submit for grading to confirm two tests pass.
Ex: If input is:
Sample output is:
****
****
****
****
****
****
Step 2 (3 pts). Input the arrow head width and draw a right triangle. Hint: use a nested loop. Submit for grading to confirm four tests pass.
Ex: If input is:
Sample output is:
***
***
***
***
****
***
**
*
Step 3 (4 pts). Modify the program to only accept an arrow head width that is larger than the arrow base width. Use a loop to continue inputting the arrow head width until the value is larger than the arrow base width. Submit for grading to confirm all tests pass.
Ex: If input is:
Sample output is:
***
***
***
***
****
***
**
*
This is my code:
#include <iostream>
using namespace std;
int main() {
int arrowBaseHeight = 0;
int arrowBaseWidth = 0;
int arrowHeadWidth = 0;
int i = 0;
int j = 0;
int x = 0;
int y = 0;
cin >> arrowBaseHeight;
cin >> arrowBaseWidth;
cin >> arrowHeadWidth;
for (i = 0; i <= arrowBaseHeight; i++){
for (j = 0; j < arrowBaseWidth; j++){
cout << "*";
}
cout << endl;
}
for (x = arrowHeadWidth; x > 0; x--){
for (y = 0; y < x; y++){
cout << "*";
}
cout << endl;
}
return 0;
}