C++ Program:

- To print full blank square pattern using *

Example:

User Input: 3

Output:

* * *
*   *
* * *
#include <iostream>
using namespace std;

int main() {
  int rows;
  cout<<"Enter number of rows: ";
  cin>>rows;
  for(int i=1; i<=rows; i++) {
    for(int j=1; j<=rows; j++) {
      if(i==1||i==rows||j==1||j==rows)cout<<"* ";
      else cout<<"  ";
    }
    cout<<endl;
  }
  return 0;
}

Output:

Enter number of rows: 6

* * * * * *
*         *
*         *
*         *
*         *
* * * * * *
Program
pattern

Main Logic :

for(int i=1; i<=rows; i++) {
  for(int j=1; j<=rows; j++) {
    if(i==1||i==rows||j==1||j==rows)cout<<"* ";
    else cout<<"  ";
  }
  cout<<endl;
}

You can print any thing in this pattern, just replace your value with *

Concept

Coming Soon !

Quick
Tutorial

Quote

Make bold choices and make mistakes. It’s all those things that add up to the person you become.