Pattern #17

Example#1: C program to generate pattern 17

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

Output:

Facebook Comments

Back to Top