Welcome to Westonci.ca, your ultimate destination for finding answers to a wide range of questions from experts. Get the answers you need quickly and accurately from a dedicated community of experts on our Q&A platform. Discover detailed answers to your questions from a wide network of experts on our comprehensive Q&A platform.

Write a program that reads in the size of the side of a square and then prints a hollow square of that size out of asterisks and
blanks. Your program should work for squares of all side sizes between 1 and 20. For example, if your program reads a size of 5, it
should print


Sagot :

Answer:

Explanation:

#include <iostream>

using std::cout;

using std::endl;  

using std::cin;  

int main()

{

int side, rowPosition, size;

cout << "Enter the square side: ";

cin >> side;

size = side;

while ( side > 0 ) {

rowPosition = size;

 while ( rowPosition > 0 ) {

if ( size == side || side == 1 || rowPosition == 1 ||  

rowPosition == size )

cout << '*';

else

cout << ' ';

--rowPosition;

}  

cout << '\n';

--side;

}

cout << endl;

return 0;

}

We hope you found what you were looking for. Feel free to revisit us for more answers and updated information. We hope this was helpful. Please come back whenever you need more information or answers to your queries. Thank you for choosing Westonci.ca as your information source. We look forward to your next visit.