Pattern 1:
/*
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
*/
# include <stdio.h>
int main()
{
int i,j;
for(i=1;i<=5;i++)
{
for(j=1;j<=i;j++)
{
printf("%d ",j);
}
printf("\n");
}
return 0;
}
Pattern 2:
/*
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1
*/
# include <stdio.h>
int main()
{
int i,j;
for(i=5;i>=1;i--)
{
for(j=1;j<=i;j++)
{
printf("%d ",j);
}
printf("\n");
}
return 0;
}
Pattern 3:
/*
5
5 4
5 4 3
5 4 3 2
5 4 3 2 1
*/
# include <stdio.h>
int main()
{
int i,j;
for(i=5;i>=1;i--)
{
for(j=5;j>=i;j--)
{
printf("%d ",j);
}
printf("\n");
}
return 0;
}
Pattern 4:
/*
5 4 3 2 1
5 4 3 2
5 4 3
5 4
5
*/
# include <stdio.h>
int main()
{
int i,j;
for(i=1;i<=5;i++)
{
for(j=5;j>=i;j--)
{
printf("%d ",j);
}
printf("\n");
}
return 0;
}
Pattern 5:
/*
1
1 3
1 3 5
1 3 5 7
1 3 5 7 9
*/
# include <stdio.h>
int main()
{
int i,j;
for(i=1;i<=9;i=i+2)
{
for(j=1;j<=i;j=j+2)
{
printf("%d ",j);
}
printf("\n");
}
return 0;
}
Pattern 6:
/*
*
* *
* * *
* * * *
* * * * *
*/
# include <stdio.h>
int main()
{
int i,j;
for(i=1;i<=5;i++)
{
for(j=1;j<=i;j++)
{
printf("* ");
}
printf("\n");
}
return 0;
}
Pattern 7:
/*
1 2 3 4 5
2 3 4 5
3 4 5
4 5
5
*/
# include <stdio.h>
int main()
{
int i,j;
for(i=1;i<=5;i++)
{
for(j=i;j<=5;j++)
{
printf("%d ",j);
}
printf("\n");
}
return 0;
}
Pattern 8:
/*
5
4 5
3 4 5
2 3 4 5
1 2 3 4 5
*/
# include <stdio.h>
int main()
{
int i,j;
for(i=5;i>=1;i--)
{
for(j=i;j<=5;j++)
{
printf("%d ",j);
}
printf("\n");
}
return 0;
}
Pattern 9:
/*
5 4 3 2 1
4 3 2 1
3 2 1
2 1
1
*/
# include <stdio.h>
int main()
{
int i,j;
for(i=5;i>=1;i--)
{
for(j=i;j>=1;j--)
{
printf("%d ",j);
}
printf("\n");
}
return 0;
}
Pattern 10:
/*
* * * * *
* * * *
* * *
* *
*
*/
# include <stdio.h>
int main()
{
int i,j;
for(i=5;i>=1;i--)
{
for(j=i;j>=1;j--)
{
printf("* ");
}
printf("\n");
}
return 0;
}
Pattern 11:
/*
1 2 3 4 5
2 3 4 5
3 4 5
4 5
5
*/
# include <stdio.h>
int main()
{
int i,j;
for(i=1;i<=5;i++)
{
for(j=1;j<=5;j++)
{
if(i<=j)
{
printf("%d ",j);
}
else
{
printf(" ");
}
}
printf("\n");
}
return 0;
}
Pattern 12:
/*
1
2
3
4
5
*/
# include <stdio.h>
int main()
{
int i,j;
for(i=1;i<=5;i++)
{
for(j=1;j<=5;j++)
{
if(i==j)
{
printf("%d ",j);
}
else
{
printf(" ");
}
}
printf("\n");
}
return 0;
}
Pattern 13:
/*
* * * * *
* * * *
* * *
* *
*
*/
# include <stdio.h>
int main()
{
int i,j;
for(i=1;i<=5;i++)
{
for(j=1;j<=5;j++)
{
if(i<=j)
{
printf("* ");
}
else
{
printf(" ");
}
}
printf("\n");
}
return 0;
}
Pattern 14:
/*
*
*
*
*
*
*/
# include <stdio.h>
int main()
{
int i,j;
for(i=1;i<=5;i++)
{
for(j=1;j<=5;j++)
{
if(i==j)
{
printf("* ");
}
else
{
printf(" ");
}
}
printf("\n");
}
return 0;
}
Pattern 15:
/*
1 1
2 2
3
4 4
5 5
*/
# include <stdio.h>
int main()
{
int i,j;
for(i=1;i<=5;i++)
{
for(j=1;j<=5;j++)
{
if(i==j || i+j==6)
{
printf("%d ",i);
}
else
{
printf(" ");
}
}
printf("\n");
}
return 0;
}
Pattern 16:
/*
*
* * *
* * * * *
* * * * * * *
* * * * * * * * *
*/
# include <stdio.h>
int main()
{
int i,j,a=5,k;
printf("\n\n");
for(i=5;i>=1;i--)
{
for(j=1;j<=i;j++)
{
printf(" ");
}
for(k=5;k>=a;k--)
{
printf(" * ");
}
a=a-2;
printf("\n\n");
}
}
Pattern 17:
/*
+ +
+ + + + + +
+ + + + + + + + + +
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + +
*/
# include <stdio.h>
int main()
{
int i,j,a=1,k,b=9,m,c=1,s;
printf("\n");
for(i=5;i>=1;i--)
{
for(j=1;j<=i;j++)
{
printf(" ");
}
for(k=1;k<=a;k++)
{
printf(" +");
}
a=a+2;
for(m=1;m<=b;m++)
{
printf(" ");
}
b=b-2;
for(s=1;s<=c;s++)
{
printf(" +");
}
c=c+2;
printf("\n");
}
}
Pattern 18:
/*
+
+ + +
+ + + + +
+ + + + + + +
+ + + + + + + + +
+ + + + + + +
+ + + + +
+ + +
+
*/
# include <stdio.h>
int main()
{
int i,j,a=1,k,I,J,A=7,K;
printf("\n");
for(i=5;i>=1;i--)
{
for(j=1;j<=i;j++)
{
printf(" ");
}
for(k=1;k<=a;k++)
{
printf(" +");
}
a=a+2;
printf("\n");
}
for(I=2;I<=5;I++)
{
for(J=1;J<=I;J++)
{
printf(" ");
}
for(K=1;K<=A;K++)
{
printf(" +");
}
A=A-2;
printf("\n");
}
}
Pattern 19:
/*
1
1 2 1
1 2 3 2 1
1 2 3 4 3 2 1
1 2 3 4 5 4 3 2 1
1 2 3 4 3 2 1
1 2 3 2 1
1 2 1
1
*/
# include <stdio.h>
int main()
{
int i,j,k,a=1,b=1,m,I,J,A=4,K,M,B=3;
for(i=5;i>=1;i--)
{
for(j=1;j<=i;j++)
{
printf(" ");
}
for(k=1;k<=a;k++)
{
printf(" %d",k);
}
a++;
for(m=b-1;m>=1;m--)
{
printf(" %d",m);
}
b++;
printf("\n");
}
for(I=2;I<=5;I++)
{
for(J=1;J<=I;J++)
{
printf(" ");
}
for(K=1;K<=A;K++)
{
printf(" %d",K);
}
A--;
for(M=B;M>=1;M--)
{
printf(" %d",M);
}
B--;
printf("\n");
}
}
Pattern 20:
/*
H
H O
H O N
H O N E
H O N E Y
*/
# include <stdio.h>
# include <string.h>
int main()
{
char a[20]={"HONEY"};
int LEN,i,j;
LEN = strlen(a);
for(i=0;i<LEN;i++)
{
for(j=0;j<=i;j++)
{
printf("%c ",a[j]);
}
printf("\n");
}
return 0;
}
Pattern 21:
/*
1
1 2 1
1 2 3 2 1
1 2 3 4 3 2 1
1 2 3 4 5 4 3 2 1
*/
# include<stdio.h>
int main()
{
int i,j,k,m,a=1,b=1;
for(i=5;i>=1;i--)
{
for(j=1;j<=i;j++)
{
printf(" ");
}
for(k=1;k<=a;k++)
{
printf("%d ",k);
}
a++;
for(m=b-1;m>=1;m--)
{
printf("%d ",m);
}
b++;
printf("\n");
}
return 0;
}
Pattern 22:
/*
+ + + + +
+ +
+ +
+ +
+ + + + +
*/
# include <stdio.h>
int main()
{
int i,j;
for(i=1;i<=5;i++)
{
for(j=1;j<=5;j++)
{
if(i==1 || i==5 || j==1 || j==5)
{
printf(" +");
}
else
{
printf(" ");
}
}
printf("\n");
}
return 0;
}
//Pattern 23:
/*
+ +
+ +
+
+ +
+ +
*/
# include <stdio.h>
int main()
{
int i,j;
for(i=1;i<=5;i++)
{
for(j=1;j<=5;j++)
{
if(i==j || i+j==6)
{
printf(" +");
}
else
{
printf(" ");
}
}
printf("\n");
}
return 0;
}
// Pattern 24:
/*
+
+
+ + + + +
+
+
*/
# include <stdio.h>
int main()
{
int i,j;
for(i=1;i<=5;i++)
{
for(j=1;j<=5;j++)
{
if(i==3 || j==3)
{
printf(" +");
}
else
{
printf(" ");
}
}
printf("\n");
}
return 0;
}
// Pattern 25:
/*
7
7 *
7 * 8
7 * 8 *
7 * 8 * 6
*/
# include <stdio.h>
# include <string.h>
int main()
{
char a[20]={"7*8*6"};
int LEN,i,j;
LEN = strlen(a);
for(i=0;i<LEN;i++)
{
for(j=0;j<=i;j++)
{
printf("%c ",a[j]);
}
printf("\n");
}
return 0;
}
// Pattern 26:
/*
A
A B
A B C
A B C D
A B C D E
*/
# include <stdio.h>
int main()
{
char i,j;
for(i='A';i<='E';i++)
{
for(j='A';j<=i;j++)
{
printf("%c ",j);
}
printf("\n");
}
return 0;
}
//Pattern 27:
/*
A B C D E
A B C D
A B C
A B
A
*/
# include <stdio.h>
int main()
{
char i,j;
for(i='E';i>='A';i--)
{
for(j='A';j<=i;j++)
{
printf("%c ",j);
}
printf("\n");
}
return 0;
}
// Pattern 28:
/*
E D C B A
D C B A
C B A
B A
A
*/
# include <stdio.h>
int main()
{
char i,j;
for(i='E';i>='A';i--)
{
for(j=i;j>='A';j--)
{
printf("%c ",j);
}
printf("\n");
}
return 0;
}
// Pattern 29:
/*
1
2 1
1 2 3
4 3 2 1
1 2 3 4 5
*/
# include <stdio.h>
int main()
{
int i,j;
for(i=1;i<=5;i++)
{
if(i%2!=0)
{
for(j=1;j<=i;j++)
{
printf("%d ",j);
}
printf("\n");
}
else
{
for(j=i;j>=1;j--)
{
printf("%d ",j);
}
printf("\n");
}
}
return 0;
}
// Pattern 30:
/*
1
2 3
4 5 6
7 8 9 10
11 12 13 14 15
*/
# include <stdio.h>
int main()
{
int i,j,k=1;
for(i=1;i<=5;i++)
{
for(j=1;j<=i;j++)
{
printf(" %d ",k);
k++;
}
printf("\n");
}
return 0;
}
// Pattern 31:
/*
1 2 3 4 5
6 7 8 9
10 11 12
13 14
15
*/
# include <stdio.h>
int main()
{
int i,j,k=1;
for(i=5;i>=1;i--)
{
for(j=1;j<=i;j++)
{
printf("%d ",k);
k++;
}
printf("\n");
}
return 0;
}
// Pattern 32:
// PASCAL TRIANGLE using ARRAY
/*
for 5 lines
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
*/
#include <stdio.h>
int main()
{
int arr[10][10];
int i=0,j=0,n=0;
printf("How many lines of Pascal Triangle u want to print: ");
scanf("%d", &n);// let n = 5
for (i=0; i<n; i++) // i = 0 to 4
{
for (j=0; j<n-1-i; j++)
/*
----BLANK SPACES----
when i = 0, j=0 to < 4 (5-1-0)
when i = 1, j=0 to < 3 (5-1-1)
when i = 2, j=0 to < 2 (5-1-2)
when i = 3, j=0 to < 1 (5-1-3)
when i = 4, j=0 to < 0 (5-1-4)
*/
printf(" ");
for (j=0; j<=i; j++)
{
if (j==0 || j==i)
/*
for 1st and last location print 1
*/
arr[i][j] = 1;
else
/*
arr[0][0]
arr[1][0] arr[1][1]
arr[2][0] arr[2][1] arr[2][2]
arr[3][0] arr[3][1] arr[3][2] arr[3][3]
arr[4][0] arr[4][1] arr[4][2] arr[4][3] arr[4][4]
for i=2,j=1
arr[2][1] = arr[1][0] + arr[1][1]
for i=3,j=1
arr[3][1] = arr[2][0] + arr[2][1]
for i=3,j=2
arr[3][2] = arr[2][1] + arr[2][2]
*/
arr[i][j] = arr[i-1][j-1] + arr[i-1][j];
printf("%d ", arr[i][j]);
}
printf("\n");
}
return 0;
}
// Pattern 33:
/*
+ . + . +
. + . + .
+ . + . +
. + . + .
+ . + . +
*/
# include <stdio.h>
int main()
{
int i,j;
for(i=1;i<=5;i++)
{
for(j=1;j<=5;j++)
{
if((i+j)%2==0)
{
printf(" +");
}
else
{
printf(" .");
}
}
printf("\n");
}
return 0;
}
// Pattern 34:
/*
9
9 8 7
9 8 7 6 5
9 8 7 6 5 4 3
9 8 7 6 5 4 3 2 1
*/
# include<stdio.h>
int main()
{
int i,j,k,a=9;
for(i=5;i>=1;i--)
{
for(j=1;j<=i;j++)
{
printf(" ",j);
}
for(k=9;k>=a;k--)
{
printf("%d ",k);
}
a=a-2;
printf("\n");
}
return 0;
}
// Pattern 35:
/*
9
9 8 7
9 8 7 6 5
9 8 7 6 5 4 3
9 8 7 6 5 4 3 2 1
9 8 7 6 5 4 3
9 8 7 6 5
9 8 7
9
*/
# include<stdio.h>
int main()
{
int i,j,k,a=9;
int I,J,K,A=3;
for(i=5;i>=1;i--)
{
for(j=1;j<=i;j++)
{
printf(" ");
}
for(k=9;k>=a;k--)
{
printf("%d ",k);
}
a=a-2;
printf("\n");
}
for(I=1;I<=5;I++)
{
for(J=1;J<=I+1;J++)
{
printf(" ");
}
for(K=9;K>=A;K--)
{
printf("%d ",K);
}
A=A+2;
printf("\n");
}
return 0;
}
// Pattern 36:
/*
1
1 2 1
1 2 3 2 1
1 2 3 4 3 2 1
1 2 3 4 5 4 3 2 1
1 2 3 4 3 2 1
1 2 3 2 1
1 2 1
1
*/
# include<stdio.h>
int main()
{
int i,j,k,m,a=1,b=1;
int I,J,K,M,A=4,B=3;
for(i=5;i>=1;i--)
{
for(j=1;j<=i;j++)
{
printf(" ");
}
for(k=1;k<=a;k++)
{
printf("%d ",k);
}
a++;
for(m=b-1;m>=1;m--)
{
printf("%d ",m);
}
b++;
printf("\n");
}
for(I=1;I<=5;I++)
{
for(J=1;J<=I+1;J++)
{
printf(" ");
}
for(K=1;K<=A;K++)
{
printf("%d ",K);
}
A--;
for(M=B;M>=1;M--)
{
printf("%d ",M);
}
B--;
printf("\n");
}
return 0;
}