forked from hDmtP/C-language-Tutorial
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstar.c
More file actions
41 lines (34 loc) · 765 Bytes
/
star.c
File metadata and controls
41 lines (34 loc) · 765 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
37
38
39
40
41
#include <stdio.h>
int main()
{
int i, j, input, res;
printf("Press 0 to print tringular pattern and 1 for reverse tringular pattern: \n");
scanf("%d", &input);
printf("Enter number of rows to print in pattern: ");
scanf("%d", &res);
const int rest = res;
if (input == 0)
{
for(i=1;i<=res;i++)
{
for(j=1;j<=i;j++)
{
printf("*");
}
printf("\n");
}
}
else
{
for(i=1;i<=rest;i++)
{
res--;
for(j=1;j<=res+1;j++)
{
printf("*");
}
printf("\n");
}
}
return 0;
}