Hey guys i have a small problem i would love some advice..this code outputs a hollowed box the problem is i cant get the right most column of the box in the right postion without tabbing it across..which will create problems if i want the user to determine how big the box should be...how can i fix this the left most column works fine when i printf when c is at 0 why doesnt the right most column do the same when c is at 9?
#include <stdio.h>
#include <conio.h>
int main()
{
int r,c;
printf("\n");
for (r=0; r<10; r++) // Loop runs 10 times(0 to 9)
{
for (c=0; c<10; c++)
{
if(r==0 || r==9) //output top and bottom of box
{
printf("*");
}
else if(c==0 )
printf("*"); // output when c at 0 (LEFT column)
else if(c==9)
printf("*"); // output when c at 9(RIGHT column)
printf(" "); //output a blank space when if not true
}
printf("\n"); //goes to a newline after main body of code is executed
}
getch();
}