-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathesercizio.c
More file actions
36 lines (34 loc) · 812 Bytes
/
esercizio.c
File metadata and controls
36 lines (34 loc) · 812 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/*
Write a void function called "rettangolo" in the C language that asks the user two integer r and c (to be inserted by keyboard) and prints on the terminal a rectangle made with * of size r for c.
For example, if the user type 5 for r and 4 for c the program must print this thing:
*****
* *
* *
*****
*/
void rettangolo(int r, int c)
{
int i, j;
for (i = 0; i < r; i++)
{
for (j = 0; j < c; j++)
{
if (i == 0 || i == r - 1)
printf("*");
else if (j == 0 || j == c - 1)
printf("*");
else
printf(" ");
}
printf("\n");
}
}
void main()
{
int r, c;
printf("Inserisci r: ");
scanf("%d", &r);
printf("Inserisci c: ");
scanf("%d", &c);
rettangolo(r, c);
}