C Program to draw Number pattern IX

Description

Input:
5
Output:
1
23
456
78910
1112131415
78910
456
23
1

Solution

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

Explanation

Refer Video tutorial