The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Jul 2017 |
| Last Sign in: | 337 Weeks Ago |
| Questions Answered: | 15833 |
| Tutorials Posted: | 15827 |
MBA,PHD, Juris Doctor
Strayer,Devery,Harvard University
Mar-1995 - Mar-2002
Manager Planning
WalMart
Mar-2001 - Feb-2009
Can you help me with this code? I have 5 different outputs listed below. I only need number 5 to be corrected but output 1 - 4 still need to be correct after any code changes.
Here is my code:
#include <iostream>
using namespace std;
int main() {
int arrowBaseHeight = 0;
int arrowBaseWidth = 0;
int arrowHeadWidth = 0;
int i, j;
cout << "Enter arrow base height: " << endl;
cin >> arrowBaseHeight;
cout << "Enter arrow base width: " << endl;
cin >> arrowBaseWidth;
cout << "Enter arrow head width: " << endl;
cin >> arrowHeadWidth;
// Draw arrow base
while(arrowBaseHeight--)
{ for(i=arrowBaseWidth; i>0; i--)
{ cout << "*";}
cout << endl;}
// Draw arrow head
while(arrowHeadWidth)
{
for(i=arrowHeadWidth; i>0; i--)
cout<< "*";
cout << endl;
arrowHeadWidth--;
}
return 0;
}
1. Compare output - Correct
Input
5
2
4
Your output
Enter arrow base height:
Enter arrow base width:
Enter arrow head width:
**
**
**
**
**
****
***
**
*
2. Compare output - Correct
Input
2
3
4
Your output
Enter arrow base height:
Enter arrow base width:
Enter arrow head width:
***
***
****
***
**
*
3. Compare output - Correct
Input
3
3
7
Your output
Enter arrow base height:
Enter arrow base width:
Enter arrow head width:
***
***
***
*******
******
*****
****
***
**
*
4. Compare output - Correct
Input
5
1
3
Your output
Enter arrow base height:
Enter arrow base width:
Enter arrow head width:
*
*
*
*
*
***
**
*
5. Compare output
Input
2
4
3
4
8
Your output
Enter arrow base height:
Enter arrow base width:
Enter arrow head width:
****
****
***
**
*
Expected output
Enter arrow base height:
Enter arrow base width:
Enter arrow head width:
Enter arrow head width:
Enter arrow head width:
****
****
********
*******
******
*****
****
***
**
*
----------- ----------- H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly