# Loop Problem..can you help please?

This is a discussion on Loop Problem..can you help please? within the C Programming forums, part of the General Programming Boards category; Hi, I have program I am working on that will print out a square made out of astericks, depending on ...

1. ## Loop Problem..can you help please?

Hi,
I have program I am working on that will print out a square made out of astericks, depending on what the operator puts in. ie..4
***** The number entered must be between 4 and 20, between
* * being the magic word. I can have it so that if you put in
* * the number 21 or higher, it gives the operator an error
* * statement. Great! But when I put in 4, it begins a loop.
***** Any help on this irratating problem would be most appreciated.. Thanks..Debbie

/* Action begins here. */

printf("Make a square out of astericks!\n");

printf("Enter a number between 4 and 20:\t \n");
scanf("%d", &limit);

/*Checking to see if entered number is between 4 and 20*/
while ( limit < 4 || limit > 20) {
printf("Again, please enter a number between 4 and 20: \n");
scanf("%d", &limit);
}

2. for 4...
Code:
```*****
*   *
*   *
*   *
*****```
Just look at what the lines you print are, and how many times you print 'm...

1. Prints a line of 5 (that is... 4 +1) *s (loop here)
2. Prints 3 lines of * * (that is, 4 - 1 lines... each line has 4 - 1 spaces... you're going to have to use two loops here)
3. Prints a line of 5 (that is 4 + 1) *s (loop here)

So you'll need a loop that can print n + 1 *s

You'll need a loop that can print * * with n - 1 spaces

And you'll need a loop which can call that last loop n - 1 times.

3. Thank you!!
Sorry it took so long to reply..flu hit here.. How much fun it was to be a mom, do the homework/programs, loose time at work and still try to maintain a sick house!

Your help was GREAT...Took me a bit but it fell into place! Thanks again!
Debbie