Algorithm To Print A Hollow Square Of Stars
ALGORITHM:
Step 1:
Start the program and get the value of n from the user
Step 2:
Initialize two nested loops for rows and columns
Step 3:
Initialize the variable i to 0 and loop through until i < n
Step 4:
Within the i-loop, initialize the variable j to 0 and loop through until j < n
Step 5:
Within the j-loop, add an if-else statement to check if i=0 or j=0 or j=n-1 or i=n-1
Step 6:
If the condition is true, print a “*” character
Step 7:
If the condition is false, print a blank space “ “
Step 8:
After printing each character, increment the value of j by 1
Step 9:
After the j-loop, add a command to create a new line
Step 10:
After the i-loop, end the program
FLOWCHART: