Question: This program is supposed to make a NxN box when you type in a number N into the program. The right side of the box
This program is supposed to make a NxN box when you type in a number N into the program. The right side of the box is always messed up. Can anyone help me find out the solution to this? Included is my code and a picture of when it is compiled
.

As you can see the right side is always messed up, it should be a normal box.
code:
#include
int main()
{
int n,i,j;
printf("enter the value of n ");
scanf("%d",&n); // reading the n value
for (i=0;i
{
if (i==0 || i==n-1) //checking first and last line
{
for (j=0;j printf("* "); //printing all stars in first and last line } else { printf("* "); // apart from first and last line printing first * for(j=2;j printf(" "); // printing remaining spaces printf("* "); // printing last star } printf(" "); //printing new line } return 0; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
