C Program to Print Square of Right Increment Numbers Pattern

Write a C program to print square of right increment numbers pattern using for loop.

#include <stdio.h>

int main()
{
	int rows;

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

	printf("Square of Increment Numbers from Right Side\n");

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

This C program prints the square pattern of increment numbers from the right side using a while loop.

#include <stdio.h>

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

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

	printf("Square of Increment Numbers from Right Side\n");
	i = 1;

	while (i <= rows)
	{
		j = 1;
		while (j <= rows - i)
		{
			printf("1 ");
			j++;
		}

		k = 1;
		while (k <= i)
		{
			printf("%d ", i);
			k++;
		}
		printf("\n");
		i++;
	}
}

This C example uses the squareIncrementNum function to print the square pattern where its numbers are incremented from the right hand side.

#include <stdio.h>

void squareIncrementNum(int rows);

int main()
{
	int rows;

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

	printf("Square of Increment Numbers from Right Side\n");
	squareIncrementNum(rows);
}

void squareIncrementNum(int rows)
{
	for (int i = 1; i <= rows; i++)
	{
		for (int j = 1; j <= rows - i; j++)
		{
			printf("1 ");
		}
		for (int k = 1; k <= i; k++)
		{
			printf("%d ", i);
		}
		printf("\n");
	}
}
Enter Square of Right Increment Numbers Rows = 9
Square of Increment Numbers from Right Side
1 1 1 1 1 1 1 1 1 
1 1 1 1 1 1 1 2 2 
1 1 1 1 1 1 3 3 3 
1 1 1 1 1 4 4 4 4 
1 1 1 1 5 5 5 5 5 
1 1 1 6 6 6 6 6 6 
1 1 7 7 7 7 7 7 7 
1 8 8 8 8 8 8 8 8 
9 9 9 9 9 9 9 9 9