Answer to Question #209883 in C++ for Ahmad

Question #209883

Apply nested loop concept to generate following pattern in output. However, number of times “$” sign get repeated in first row will be defined by the last digit of your SAP-ID+1


1
Expert's answer
2021-06-23T10:10:28-0400
#include <iostream>

using namespace std;

int main()
{
  int n, m;
  cin >> n >> m;
  char sign = '$';
  for (int i=0; i<n; i++) {
    for (int j=0; j<m; j++) {
      if (i==0 or i==n-1 or j==0 or j==m-1)
        cout << sign;
      else
        cout << ' ';
    }
    cout << endl;
  }
  return 0;
}

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