Week 2 Classwork
Plus-sized Plus
Design a function that prints out a plus sign composed of '+' characters that is n lines high and n lines wide. We'll have the user provide n via prompt, and output an error if n is even.
#include <iostream>
#include <string>
using namespace std;
int main () {
int dimensions;
cout << "Input an odd dimension: ";
cin >> dimensions;
if (dimensions % 2 == 0) {
cout << "Invalid dimensions!" << endl;
return 1;
}
for (int i = 0; i < dimensions; i++) {
for (int j = 0; j < dimensions; j++) {
if (j == dimensions / 2 || i == dimensions / 2) {
cout << "+";
} else {
cout << " ";
}
}
cout << endl;
}
}