Answer to Question #89945 in C++ for matimu

Question #89945
Write a C++ Program to draw 2 rectangles and fill One of them.
1
Expert's answer
2019-05-21T08:06:32-0400
#include <iostream>
using namespace std;


int main() {
  // 1st rectangle
  for (int i = 0; i < 5; ++i) {
    for (int j = 0; j < 10; ++j) {
      if (
        i == 0 || i == 4 ||
        j == 0 || j == 9
      ) {
        cout << "*";
      } else {
        cout << " ";
      }
    }
    cout << endl;
  }


  cout << endl;


  // 2nd rectangle (filled)
  for (int i = 0; i < 5; ++i) {
    for (int j = 0; j < 10; ++j) {
      cout << "*";
    }
    cout << endl;
  }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS