+ 1
How can I draw a rectangle in a frame using loops inc++?
The code for Rectangle
4 Answers
+ 2
for(int i =0; i<5; i++){
if(i == 0 || i ==4) { //first and last
cout << "*****************************";
} else {
cout << "* *";
}
}
This should do it. You can adjust the length manually, as well as the height.
+ 1
What you have so far? Make an attempt.. If you struck, then some one from community help you in better way..
Hope you understand.. That would be best practice.
Edit:
Just use a loop, for 2 dimensional array, when
Either i, or j=0, or n(last row, print wall or char..) else leave a space..
So first row, and colomn, last row, and colomn need a char print everything else print a space...
+ 1
Is it a text based rectangle? Is it a hollow or filled rectangle?
0
Think loops and nested loops.