+ 2

Help me fix this code

Please help me fix this code, it should be print like a box with pound sign as a fence. But there was another pound sign far from the box showed up. Anyone can help me, please? Thanks and sorry for my english ######### # # # # # # # # # # # ######### https://code.sololearn.com/c4Nf30mDfup6/?ref=app

30th Mar 2018, 10:38 AM
pratama
pratama - avatar
5 Answers
+ 1
You aren't printing a new line after the first loop. And also you have to print "#" in the first loop "width + 1" times as you do in the third loop.
30th Mar 2018, 11:03 AM
Dharma Teja
Dharma Teja - avatar
+ 1
There should be an endl after the first for statement (in line 15): cout << endl;
30th Mar 2018, 10:56 AM
Paul
Paul - avatar
+ 1
ok thanks it work
30th Mar 2018, 12:04 PM
pratama
pratama - avatar
+ 1
If I may suggest another change? I would change line 22 from if(i==9) to if (i == width -1) Your code will then still work if you change the width to another value.
30th Mar 2018, 12:09 PM
Paul
Paul - avatar
0
ok I will try it
30th Mar 2018, 12:59 PM
pratama
pratama - avatar