72: Write a program in C++ to print a square pattern with # character.
// Write a program in C++ to print a square pattern with # character. Go to the editor
// Sample Output:
// Print a pattern like square with # character:
// --------------------------------------------------
// Input the number of characters for a side: 4
// # # # #
// # # # #
// # # # #
// # # # #
// **************************************************************************************************
#include <iostream>
using namespace std;
int main()
{
int num;
cout << "\nPrint a pattern like square with # character: \n";
cout << "\n----------------------------------------------------\n\n";
cout << "Input the number of characters for a side: ";
cin >> num;
cout << endl;
for (int i = 1; i <= num; i++)
{
for (int j = 1; j <= num; j++)
{
cout << '#' ;
}
cout << endl;
}
cout << "\n******************************************************\n\n";
return 0;
}
Comments
Post a Comment