C program pattern 11111 11111 11111 11111

Pattern programs can be a little bit tricky, but if we know the basic concepts and logic behind the given pattern, we can easily write a C program to create that pattern. In this article, we are going to understand and create a simple pattern through our C program, which looks like this –

11111
11111
11111
11111
11111

If you observe this pattern, we have 5 rows(which can be taken as user input), and 5 columns, which makes this a kind of square pattern(you can also take a different number of columns). In each instance, we need to put the number “1”(you can choose any other character).

C Program Pattern 11111 11111 11111 11111

In the given video, you can find an easy explanation along with a video to understand and create the above-given pattern.

Here is the program to create such a pattern –

#include <stdio.h>

int main() {
int rows, columns;

printf("Enter the number of rows: ");
scanf("%d", &rows);

for (int i = 1; i <= rows; i++) {
for (int j = 1; j <= rows; j++) {
printf("1");
}
printf("n");
}

return 0;
}

Program Output 1 – 

Enter the number of rows: 5
11111
11111
11111
11111
11111

Program Output 2 – 

Enter the number of rows: 7
1111111
1111111
1111111
1111111
1111111
1111111
1111111