-
Notifications
You must be signed in to change notification settings - Fork 26
/
multipleFunctions.c
48 lines (42 loc) · 934 Bytes
/
multipleFunctions.c
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
37
38
39
40
41
42
43
44
45
46
47
48
#include <stdio.h>
void printLine(int nCols, char pattern);
void printTriangle(int nLines, char pattern);
void printRectangle(int nLines, int nCols, char pattern);
int main(void)
{
int nCols;
int nLines;
printf("How many columns would you like? ");
scanf("%d", &nCols);
printLine(nCols, 'X');
printf("How many lines would you like? ");
scanf("%d", &nLines);
printTriangle(nLines, '*');
printf("\n");
printRectangle(nLines, nCols, '#');
}
void printLine(int nCols, char pattern)
{
int i;
for (i = 0; i < nCols; i++)
{
printf("%c", pattern);
}
printf("\n");
}
void printTriangle(int nLines, char pattern)
{
int line, cols;
for (line = 0; line < nLines; line++)
{
cols = line + 1;
printLine(cols, pattern);
}
}
void printRectangle(int nLines, int nCols, char pattern)
{
int i;
for (i = 0; i < nLines; i++){
printLine(nCols, pattern);
}
}