Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions patterns/equilateral_triangle.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/* *
* *
* * *
* * * * */

#include <stdio.h>
void pattern(int x);
int main()
{
int n;
printf("Enter the number of rows ");
scanf("%d",&n);
pattern(n);
return 0;
}
void pattern(int x)
{
int i, j;
for(i=1; i<=x; i++)
{
for(j=1; j<=x; j++)
{
if(j<=x-i || j>x+i)
{
printf(" ");
}
else
{
printf("* ");
}
}
printf("\n");
}
}
26 changes: 26 additions & 0 deletions patterns/half_pyramid_progressive_numbers.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*1
12
123
1234*/
#include <stdio.h>
void pattern(int x);
int main()
{
int n;
printf("Enter the number of rows ");
scanf("%d",&n);
pattern(n);
return 0;
}
void pattern(int x)
{
int i,j;
for(i=1; i<=x; i++)
{
for(j=1; j<=i; j++)
{
printf("%d",j);
}
printf("\n");
}
}
26 changes: 26 additions & 0 deletions patterns/inverted_half_pyramid.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/* ****
***
**
* */
#include <stdio.h>
void pattern(int x);
int main()
{
int n;
printf("Enter the number of rows ");
scanf("%d",&n);
pattern(n);
return 0;
}
void pattern(int x)
{
int i,j;
for(i=x; i>=1; i--)
{
for(j=1; j<=i; j++)
{
printf("*");
}
printf("\n");
}
}
26 changes: 26 additions & 0 deletions patterns/pyramid_with_numbers.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*1
22
333
4444*/
#include <stdio.h>
void pattern(int x);
int main()
{
int n;
printf("Enter the number of rows ");
scanf("%d",&n);
pattern(n);
return 0;
}
void pattern(int x)
{
int i,j;
for(i=1; i<=x; i++)
{
for(j=1; j<=i; j++)
{
printf("%d",i);
}
printf("\n");
}
}