C Program to Print Square of Left Decrement Numbers Pattern

Write a C program to print square of left decrement numbers pattern using for loop.

#include <stdio.h>

int main()
{
	int rows;

	printf("Enter Square of Left Dec Numbers Rows = ");
	scanf("%d", &rows);

	printf("Square of Decrement Numbers from Left Side\n");

	for (int i = rows; i >= 1; i--)
	{
		for (int j = i; j < rows; j++)
		{
			printf("%d ", j);
		}
		for (int k = rows - i; k < rows; k++)
		{
			printf("%d ", rows);
		}
		printf("\n");
	}
}
C Program to Print Square of Left Decrement Numbers Pattern

This C program displays the square pattern of decrement numbers from the left side using a while loop.

#include <stdio.h>

int main()
{
	int rows, i, j, k;

	printf("Enter Square of Left Dec Numbers Rows = ");
	scanf("%d", &rows);

	printf("Square of Decrement Numbers from Left Side\n");
	i = rows;

	while (i >= 1)
	{
		j = i;
		while (j < rows)
		{
			printf("%d ", j);
			j++;
		}

		k = rows - i;
		while (k < rows)
		{
			printf("%d ", rows);
			k++;
		}

		printf("\n");
		i--;
	}
}
Enter Square of Left Dec Numbers Rows = 9
Square of Decrement Numbers from Left Side
9 9 9 9 9 9 9 9 9 
8 9 9 9 9 9 9 9 9 
7 8 9 9 9 9 9 9 9 
6 7 8 9 9 9 9 9 9 
5 6 7 8 9 9 9 9 9 
4 5 6 7 8 9 9 9 9 
3 4 5 6 7 8 9 9 9 
2 3 4 5 6 7 8 9 9 
1 2 3 4 5 6 7 8 9 

About Suresh

Suresh is the founder of TutorialGateway and a freelance software developer. He specialized in Designing and Developing Windows and Web applications. The experience he gained in Programming and BI integration, and reporting tools translates into this blog. You can find him on Facebook or Twitter.