Last weekend I posted about this program to make a "table shape" out of asterisks. I am almost there except for the missing left leg of the table ,and the bottom row of asterisks does't need to be there. Any ideas? Thanks
Code:
Code:
6 #include <stdio.h>
7
8 int main(void)
9
10 {
11
12 int height, width, hgt, wdt;
13
14 printf("Enter width:");
15 scanf("%d", &width);
16 printf("Enter height:");
17 scanf("%d", &height);
18
19
20 for(hgt = 0; hgt < height; hgt++) {
21 for(wdt = 0; wdt < width - 2; wdt++) {
22 if(wdt == 0 || wdt == width- 1)
23 printf("*\n");
24 else if(hgt == 0 || hgt == height - 1)
25 printf("*");
26 else
27 printf(" ");
28 }
29 }
30 printf("\n");
31 printf("PROGRAM ENDS\n");
32 return 0;
33
34 }
Here is the output
Code:
Code:
Enter width:10
Enter height:5
*
********
*
*
*
*******
PROGRAM ENDS
Any suggestions? Thank you for help!