+ 1

C++ help !!!!!!

Make a program that displays the the content of an array that includes negative and positive values in the following format: **********-10 10********** 2** **-2 You might need a max and min functions Use setw() to display at different positions what I did is something like this #include<iostream> #include<iomanip> Using namespace std; int main() double A[6]={-10,15,-7,5,-10,16} double sum= 0; for(int i=0;i<6;i++){ for (int j=sum;j<=-1;j++) {cout<<“*”;} cout<<sum; if (sum== -2){ cout<<setw(12);} if (sum== -7){ cout<<setw(12);} if (sum== -10){ cout<<setw(12);} for(int j=1;j<=sum;j++) {cout<<“*”;} if (sum== 3){ cout<<setw(4);} if (sum== 5){ cout<<setw(9);} cout<<endl; } return0; } My attempt is not what the TA wanted. I need help please.

3rd Nov 2018, 2:55 PM
Ahmed1118
5 Answers
+ 3
To begin, you have posted this 4 times in the past. Something I think you should work on in your code is just cleaning it up. You seem to have a lot of code clumped together, so maybe try seeing other people's codes and seeing how they format it (using tabs and spaces), and try to implement that into your own codes. Another thing is that you have missed a few semicolons, which could be one of the reasons it doesn't work as expected. https://code.sololearn.com/cI69sJD9mGwv/?ref=app https://code.sololearn.com/cYRfgdBTqA4j/?ref=app https://code.sololearn.com/c0b31lV9G2ny/?ref=app https://www.sololearn.com/Discuss/1194744/?ref=app
3rd Nov 2018, 3:19 PM
Faisal
Faisal - avatar
+ 2
Hey Ahmed1118 ! I have noticed you have been posting this question several times in many different places, so at this point it may be considered spam. Please, if you have a question, just post a single question and be patient to get an answer. As for the question, if this is problem is homework, then try working on it yourself. I realize that you have already attempted to solve it yourself, but you can't have people do your work for you. What I would suggest is talking with your TA to see what you might have done wrong and what you could do to improve your answer independently. Best of luck! https://www.sololearn.com/discuss/1316935/?ref=app
3rd Nov 2018, 3:04 PM
Faisal
Faisal - avatar
+ 2
the nested loop's logic is wrong..plus through the loop the j should be decremented.You should try running the code in the playground,if it still doesnt work I'll help you out....
3rd Nov 2018, 4:49 PM
Mensch
Mensch - avatar
+ 1
Hi Faisal , it was a home work and i got graded on what I did. Now I want to know what I’ve done wrong so I could LEARN. ps the TA refused to assist me. I posted twice and I apologyze on that .
3rd Nov 2018, 3:09 PM
Ahmed1118
+ 1
Ahmed1118 here is a way you can do this simular to yours but with for loops for the stars. https://code.sololearn.com/cuC7dc0nGHbf/?ref=app
5th Nov 2018, 12:16 PM
Mooaholic
Mooaholic - avatar