Patterns Program in C : 9 numerical patterns and its C program

In this tutorial, we will learn about how to write a C Program for a different numerical pattern.

PATTERN 1:

1 2 3 4 5
1 2 3 4
1 2 3
1 2
1

C Program for PATTERN 1:

#include<stdio.h>
 int main()
 {
 int i,j,n;
 scanf("%d",&n);
 for(i=0;i<n;i++)
 {
 for(j=1;j<=n-i;j++)
 {
 printf("%d ",j);
 }
 printf("\n");
 }
 return 0;
 }

PATTERN 2:

1 2 3 4 5
2 3 4 5
3 4 5
4 5
5
C Program for PATTERN 2:

#include<stdio.h>
 int main()
 {
 int i,j,k=1,n;
 scanf("%d",&n);
 for(i=0;i<n;i++)
 {
 k=i+1;
 for(j=1;j<=n-i;j++)
 {
 printf("%d ",k);
 k++;
 }
 printf("\n");
 }
 return 0;
 }

PATTERN 3:

5 4 3 2 1 
4 3 2 1 
3 2 1 
2 1 
1

C Program for PATTERN 3:

#include<stdio.h>
 int main()
 {
 int i,j,k=1,n;
 scanf("%d",&n);
 for(i=0;i<n;i++)
 {
 k=n-i;
 for(j=1;j<=n-i;j++)
 {
 printf("%d ",k);
 k--;
 }
 printf("\n");
 }
 return 0;
 }

PATTERN 4:


1 2 
1 2 3 
1 2 3 4 
1 2 3 4 5

C Program for PATTERN 4:

#include<stdio.h>
 int main()
 {
 int i,j,n;
 scanf("%d",&n);
 for(i=1;i<=n;i++)
 {
 for(j=1;j<=i;j++)
 {
 printf("%d ",j);
 }
 printf("\n");
 }
 return 0;
 }

PATTERN 5:


4 5 
3 4 5 
2 3 4 5 
1 2 3 4 5

C Program for PATTERN 5:

#include<stdio.h>
 int main()
 {
 int i,j,k,n;
 scanf("%d",&n);
 k=n;
 for(i=0;i<n;i++)
 {
 k=n-i;
 for(j=0;j<=i;j++)
 {
 printf("%d ",k);
 k++;
 }
 printf("\n");
 }
 return 0;
 }

PATTERN 6:


2 2 
3 3 3 
4 4 4 4 
5 5 5 5 5

C Program for PATTERN 6:

#include<stdio.h>
 int main()
 {
 int n,i,j;
 scanf("%d",&n);
 for(i=1;i<=n;i++)
 {
 for(j=1;j<=i;j++)
 {
 printf("%d ",i);
 }
 printf("\n");
 }
 return 0;
 }

PATTERN 7:


4 4 
3 3 3 
2 2 2 2 
1 1 1 1 1

C Program for PATTERN 7:

#include<stdio.h>
 int main()
 {
 int i,j,n;
 scanf("%d",&n);
 for(i=0;i<n;i++)
 {
 for(j=0;j<=i;j++)
 {
 printf("%d ",n-i);
 }
 printf("\n");
 }
 return 0;
 }

PATTERN 8:

5 5 5 5 5 
4 4 4 4 
3 3 3 
2 2 
1

C Program for PATTERN 8:

 #include<stdio.h>
 int main()
 {
 int i,j,n;
 scanf("%d",&n);
 for(i=0;i<n;i++)
 {
 for(j=0;j<n-i;j++)
 {
 printf("%d ",n-i);
 }
 printf("\n");
 }
 return 0;
 }

PATTERN 9:

1 1 1 1 1 
2 2 2 2 
3 3 3 
4 4 
5

C Program for PATTERN 9:

#include<stdio.h>
 int main()
 {
 int i,j,n;
 scanf("%d",&n);
 for(i=0;i<n;i++)
 {
 for(j=1;j<=n-i;j++)
 {
 printf("%d ",i+1);
 }
 printf("\n");
 }
 return 0;
}

Leave a Reply

Shopping cart