loader image

C program to display pattern with a number

Create a pattern with the number N.

E.g. N = 39174 Pattern: 3 9 1 7 4

9 1 7 4
1 7 4
7 4
4

#include<stdio.h>
#include<conio.h>

void main()
{
	int n,l,t;
	printf("Enter a number : ");
	scanf("%d",&n);
	for(l=1,t=n/10;t!=0;t/=10,l*=10)
	;
	printf("\nThe pattern\n");
	for(t=n;t!=0;t%=l,l/=10)
		printf("\n%d",t);
}
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments