I need help writing a program. The program calls for a user to be asked a width and height to make a table of asterisks. The height can ONLY be 3 or 5, and the width can be between 4-40. The table must be out of asterisks. Here is the program I have so far, except i need to replace the word "width" with the desired width of asterisks...How can I do this?
Code:
"pe3.c" 23 lines, 228 characters
6 #include <stdio.h>
7
8 int main(void)
9
10 {
11
12 int height, width;
13
14 printf("Enter width:");
15 scanf("%d", &width);
16 printf("Enter height:");
17 scanf("%d", &height);
18
19 if (height == 3)
20 printf("%d\n", width);
21 printf("*%d*\n", width);
22 printf("*%d*\n", width);
23
24 return 0;
25
26 }
This is what the program is supposed to make:
Code:
Enter width: 20
Enter height: 3
********************
* *
* *