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
#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;
}
Comments
Leave a comment