Â
In this, we are going to see a program in which we will be printing an Adjacent Edged Square / Rectangle Number pattern as shown in above image in C Programming Language.
/*Number Pattern - (adjecent edges)
5 5 5 5 5
5 4 4 4 4
5 4 3 3 3
5 4 3 2 2
5 4 3 2 1*/
#include <stdio.h>
int main()
{
int row, col, temp;
printf("Enter no. of rows: ");
scanf("%d", &row);
printf("Enter no. of columns: ");
scanf("%d", &col);
for (int i = 0; i < row; i++)
{
temp = col;
for (int j = 0; j < col; j++)
{
if (j != 0)
{
//adds space in between chars
printf(" ");
}
printf("%d", temp);
if ((i - j) > 0)
{
temp--;
}
}
printf("\n");
}
}
#ENJOY CODING
Post a Comment
FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP