# Thread: aterisk squares!!! need help!

1. ## asterisk squares!!! need help!

I had created this code, and a lot is missing from it, the input value is "h=6" and "v=4"
it's output is:
*
*
*
*******
Code:
```#include <stdio.h>
#include <conio.h>
main()
{ int h,h1,v,v1;
printf("Enter horizontal value:\n");
scanf("%d",&h);
printf("Enter vertical value:\n");
scanf("%d",&v);
h1=0;
v1=0;
while(v1<=v) {
printf("\n*");
v1++;
while(h1<=h) {
printf("*");
h1++;
}
}
getch();
}```

the output supposed to be is an a square box of asterisk with an a 6X4 field. It should look like this:
without the dashes
******
*-----*
*-----*
******
Can anyone point me to the right direction here!!!
I'm still new to c programming, barely a month ago.
Anyone can give me a clue on this! Little and big help will be graciously accepted.

2. Code:
```for( v1 = 0; v1 < v; ++v1 )
{
for( h1 = 0; h1 < h; ++h1 )
{
if( "This is a location in the middle of the rectangle" )
putchar(' ');
else
putchar('*');
}
putchar('\n');
}```
All you need to do is figure out how to determine if you are somewhere in the middle of the rectangle based on the h1 and v1 values. Shouldn't be to difficult to put in some tests of the values. A couple tests on each of the h1 and v1 values and'ed all together should suffice.

3. hk_mp5kpdwc thanx for some help! but the program needs more than that!
I was told use the looping method! it is suppose work like this. the program ask for an input of two values, for testing i had used h=6 and v=4, it should generate an a squre box of asterisk with six horizontal asterisk on top,4 vertical asterisk on left corner and right corner to bottom, and six asterisk in the bottom! you still can use other values like 8x5,14x4 asterisk and it should generate an 8x5,14x4 square asterisk, anyways thanx again!

4. ?????

Those are loops... for loops. I just included the looping part which you could drop into the existing code you already have that asks the user for the two values (h and v). That code will work (if you figure out the missing part) for any values of h and v that the user enters.

5. ok, i give up, can you pls tell me the missing part or give me an a example! This things are too new for me to see! plsss! thnx!

6. Code:
```#include <stdio.h>
#include <conio.h>
int main()
{
int h,h1,v,v1;
printf("Enter horizontal value:\n");
scanf("%d",&h);
printf("Enter vertical value:\n");
scanf("%d",&v);
for( v1 = 0; v1 < v; ++v1 )
{
for( h1 = 0; h1 < h; ++h1 )
{
if( h1 > 0 && h1 < h-1 && "figure out the vertical test portion" )
putchar(' ');
else
putchar('*');
}
putchar('\n');
}
getch();
return 0;
}```
Blue is my code plopped directly into yours, replacing the while loops. Red is a portion of the "missing" part, I'm still going to try and get you to figure out the vertical portion of the tests; here's a hint, it is very similar to the horizontal portion already in place. Green is just a couple additions.

7. thanx a lot friend! ill try my best to figure out the red part!
thanks again!

8. Originally Posted by neosnk35
hk_mp5kpdwc thanx for some help! but the program needs more than that!

I was told use the looping method!
Oh, my sides are aching! Thanks for that!!