Pattern 23: Number Pattern in C using for loop
Program to print below number pattern :
As part of this number pattern in c program, We are going to take input number which is size or Number of rows.
Here is an example when the user input is 5.
Example:
Enter how many rows you want: 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
Number Pattern in C:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
#include<stdio.h> int main() { int i,j,n; printf("Enter how many rows you want : "); scanf("%d",&n); for(i=1;i<=n;i++) { for(j=1;j<=n;j++) printf(" %d",j); printf("\n"); } return 0; } |
Program Output:
We are running the program using the GNU gcc compiler.
You may also like:
- Basic star pattern program (The square pattern with stars).
- Triangle star pattern program.
- Triangle star pattern program with Spaces.
- Pyramid star pattern.
- Reverse Pyramid program.
- Diamond Star pattern program.
- star pattern program.
- K-Star pattern program.
- Empty Rhombus program.
- X-Star pattern program