You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// C++ program to print square inside
// a square pattern
#include
using namespace std;
// Function to print the pattern square
// inside a square
void printPattern(int n)
{
int i, j;
// To access rows of the square
for (i = 1; i <= n; i++)
{
// To access columns of the square
for (j = 1; j <= n; j++)
{
// For printing the required square pattern
if ((i == 1 || i == n || j == 1 || j == n) ||
(i >= 3 && i <= n - 2 && j >= 3 && j <= n - 2) &&
(i == 3 || i == n - 2 || j == 3 || j == n - 2))
{
// Prints star(*)
cout<<"*";
}
else
{
// Prints space(" ")
cout<<" ";
}
}
cout<<endl;
}
}
// Driver Code
int main()
{
int n = 7;
printPattern(n);
return 0;
}
The text was updated successfully, but these errors were encountered:
// C++ program to print square inside
// a square pattern
#include
using namespace std;
// Function to print the pattern square
// inside a square
void printPattern(int n)
{
int i, j;
}
// Driver Code
int main()
{
int n = 7;
printPattern(n);
return 0;
}
The text was updated successfully, but these errors were encountered: