Write a C program to print the square of the left shift numbers pattern using a for loop.
#include <stdio.h>
int main()
{
int rows;
printf("Enter Square Left Shift Numbers Rows = ");
scanf("%d", &rows);
printf("The Square Pattern of Left Shift Numbers\n");
for (int i = 1; i <= rows; i++)
{
for (int j = i; j <= rows; j++)
{
printf("%d ", j);
}
for (int k = 1; k < i; k++)
{
printf("%d ", k);
}
printf("\n");
}
}

It is the other way of writing the C program to print the square pattern of left shift numbers.
#include <stdio.h>
int main()
{
int rows;
printf("Enter Square Left Shift Numbers Rows = ");
scanf("%d", &rows);
printf("The Square Pattern of Left Shift Numbers\n");
for (int i = 1; i <= rows; i++)
{
int j = i;
for (int k = 1; k <= rows; k++)
{
printf("%d ", j);
j++;
if (j > rows)
{
j = 1;
}
}
printf("\n");
}
}
Enter Square Left Shift Numbers Rows = 15
The Square Pattern of Left Shift Numbers
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
2 3 4 5 6 7 8 9 10 11 12 13 14 15 1
3 4 5 6 7 8 9 10 11 12 13 14 15 1 2
4 5 6 7 8 9 10 11 12 13 14 15 1 2 3
5 6 7 8 9 10 11 12 13 14 15 1 2 3 4
6 7 8 9 10 11 12 13 14 15 1 2 3 4 5
7 8 9 10 11 12 13 14 15 1 2 3 4 5 6
8 9 10 11 12 13 14 15 1 2 3 4 5 6 7
9 10 11 12 13 14 15 1 2 3 4 5 6 7 8
10 11 12 13 14 15 1 2 3 4 5 6 7 8 9
11 12 13 14 15 1 2 3 4 5 6 7 8 9 10
12 13 14 15 1 2 3 4 5 6 7 8 9 10 11
13 14 15 1 2 3 4 5 6 7 8 9 10 11 12
14 15 1 2 3 4 5 6 7 8 9 10 11 12 13
15 1 2 3 4 5 6 7 8 9 10 11 12 13 14
This C example displays the square pattern of left shifted numbers from top to bottom using a while loop.
#include <stdio.h>
int main()
{
int rows, i, j, k;
printf("Enter Square Left Shift Numbers Rows = ");
scanf("%d", &rows);
printf("The Square Pattern of Left Shift Numbers\n");
i = 1;
while (i <= rows)
{
j = i;
while (j <= rows)
{
printf("%d ", j);
j++;
}
k = 1;
while (k < i)
{
printf("%d ", k);
k++;
}
printf("\n");
i++;
}
}
Enter Square Left Shift Numbers Rows = 12
The Square Pattern of Left Shift Numbers
1 2 3 4 5 6 7 8 9 10 11 12
2 3 4 5 6 7 8 9 10 11 12 1
3 4 5 6 7 8 9 10 11 12 1 2
4 5 6 7 8 9 10 11 12 1 2 3
5 6 7 8 9 10 11 12 1 2 3 4
6 7 8 9 10 11 12 1 2 3 4 5
7 8 9 10 11 12 1 2 3 4 5 6
8 9 10 11 12 1 2 3 4 5 6 7
9 10 11 12 1 2 3 4 5 6 7 8
10 11 12 1 2 3 4 5 6 7 8 9
11 12 1 2 3 4 5 6 7 8 9 10
12 1 2 3 4 5 6 7 8 9 10 11