1. Number Pattern - 1
void main()
{
int i,j,n;
printf("Enter the number of rows:");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
for(j=1;j<=i;j++)
{
printf("%d", i);
}
printf("\n");
}
}
Output :-
Enter the number of rows: 8
1
22
333
4444
55555
666666
7777777
88888888
2. Number Pattern - 2
#include<stdio.h>
void main()
{
int i,j,n;
printf("Enter the number of rows:");
scanf("%d",&n);
for(i=n;i>=1;i--)
{
for(j=1;j<=i;j++)
{
printf("%d", i);
}
printf("\n");
}
}
Output :-
Enter the number of rows: 8
8888888
7777777
666666
55555
4444
333
22
1
3. Number Pattern - 3
#include<stdio.h>
void main()
{
int i,j,n;
printf("Enter the number of rows:");
scanf("%d",&n);
printf("\n");
for(i=1;i<=n;i++)
{
for(j=1;j<=i;j++)
{
printf("%d", (n-i+1));
}
printf("\n");
}
}
Output :-
Enter the number of rows: 8
8
77
666
5555
44444
333333
2222222
11111111
4. Star Pattern - 4
#include<stdio.h>
void main()
{
int i,j,n;
printf("Enter the number of rows:");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
for(j=i;j<=n;j++)
{
printf("%d", i);
}
printf("\n");
}
}
Output :-
Enter the number of rows: 8
11111111
2222222
333333
44444
5555
666
77
8
5. Number Pattern - 5
#include<stdio.h>
void main()
{
int i,j,n;
printf("Enter the number of rows:");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
for(j=1;j<=i;j++)
{
printf("%d ",j); //print upper half
}
printf("\n");
}
for(i=n-1;i>=1;i--)
{
for(j=1;j<=i;j++)
{
printf("%d ",j); //print lower half
}
printf("\n");
}
}
Output :-
Enter the number of rows: 8
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
1 2 3 4 5 6
1 2 3 4 5 6 7
1 2 3 4 5 6 7 8
1 2 3 4 5 6 7
1 2 3 4 5 6
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1
6. Number Pattern - 6
#include<stdio.h>
void main()
{
int i,n,j;
printf("Enter the number of rows:");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
for(j=1;j<=n-i;j++)
{
printf(" ");
}
for(j=1;j<=i;j++)
{
printf("%d",j);
}
for(j=i-1;j>=1;j--)
{
printf("%d",j);
}
printf("\n");
}
}
Output :-
Enter the number of rows: 8
1
121
12321
1234321
123454321
12345654321
1234567654321
123456787654321
7. Number Pattern - 7
#include<stdio.h>
void main()
{
int coef=1,space,n,i,j;
printf("Enter the number of rows:");
scanf("%d",&n);
for(i=0;i<n;i++)
{
for(space=1;space<=n-i;space++)
printf(" ");
for(j=0;j<=i;j++)
{
if (j==0 || i==0)
coef = 1;
else
coef=coef*(i-j+1)/j;
printf("%4d",coef);
}
printf("\n");
}
}
Output :-
Enter the number of rows: 8
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
1 5 10 10 5 1
1 6 15 20 15 6 1
1 7 21 35 35 21 7 1
8. Number Pattern - 8
#include<stdio.h>
void main()
{
int i,j,n;
printf("Enter the number of rows:");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
for(j=1;j<=(i*2-1);j++)
{
printf("%d",j);
}
printf("\n");
}
}
Output :-
Enter the number of rows: 8
1
123
12345
1234567
123456789
1234567891011
12345678910111213
123456789101112131415
9. Number Pattern - 9
#include<stdio.h>
void main()
{
int i,j,n;
printf("Enter the number of rows:");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
for(j=i;j<=n;j++)
{
printf("%d",j);
}
printf("\n");
}
}
Output :-
Enter the number of rows:- 8
12345678
2345678
345678
45678
5678
678
78
8
10. Number Pattern - 10
#include<stdio.h>
void main()
{
int i,j,n;
printf("Enter the number of rows:");
scanf("%d",&n);
for(i=n;i>=1;i--)
{
for(j=i;j<=n;j++)
{
printf("%d",j);
}
printf("\n");
}
}
Output :-
Enter the number of rows: 8
8
8
78
678
5678
45678
345678
2345678
12345678
11. Number Pattern - 11
#include<stdio.h>
void main()
{
int i,j,k=1,n;
printf("Enter the number of rows:");
scanf("%d",&n);
printf("Floyd's Triangle\n");
for(i=1;i<=n;i++)
{
for(j=1;j<=i;j++,k++)
{
printf("%4d", k); //4 spaces
}
printf("\n");
}
}
Output :-
Enter the number of rows: 8
Floyd's Triangle
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
12. Number Pattern - 12
#include<stdio.h>
void main()
{
int i,j,n;
printf("Enter the number of rows:");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
for(j=1;j<=i;j++)
{
if(i%2==1)
{
printf("1 ");
}
else
{
printf("0 ");
}
}
printf("\n");
}
}
Output :-
Enter the number of rows: 8
1
0 0
1 1 1
0 0 0 0
1 1 1 1 1
0 0 0 0 0 0
1 1 1 1 1 1 1
0 0 0 0 0 0 0 0
13. Number Pattern - 13
#include<stdio.h>
void main()
{
int i,j,n;
printf("Enter the number of rows:");
scanf("%d",&n);
printf("Reverse of Floyd's Triangle\n");
int k = (n*(n+1))/2;
for(i=n;i>=1;i--)
{
for(j=i;j>=1;j--,k--)
{
printf("%4d", k); //4 spaces
}
printf("\n");
}
}
Output :-
Enter the number of rows: 8
Reverse of Floyd's Triangle
36 35 34 33 32 31 30 29
28 27 26 25 24 23 22
21 20 19 18 17 16
15 14 13 12 11
10 9 8 7
6 5 4
3 2
1
14. Number Pattern - 14
#include<stdio.h>
void main()
{
int i,n,j;
printf("Enter the number of rows:");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
for(j=1;j<=n-i;j++)
{
printf(" ");
}
for(j=i;j>0;j--)
{
printf(" %d",j);
}
for(j=2;j<=i;j++)
{
printf(" %d",j);
}
printf("\n");
}
}
Output :-
Enter the number of rows: 8
1
2 1 2
3 2 1 2 3
4 3 2 1 2 3 4
5 4 3 2 1 2 3 4 5
6 5 4 3 2 1 2 3 4 5 6
7 6 5 4 3 2 1 2 3 4 5 6 7
8 7 6 5 4 3 2 1 2 3 4 5 6 7 8
0 Comments