Pattern 39: 1-0 Number Pattern in C Programming
The 1-0 Number Pattern :
Write a C Program to print below 1-0 number pattern on the console. We are going to use the c language for loops to create the pattern.
Here are couple of example input and outputs of the pattern.
Example 1:
Enter how many rows you want : 5
 1
 1 0
 1 0 1
 1 0 1 0
 1 0 1 0 1
Example 2:
Enter how many rows you want : 10
1
1 0
1 0 1
1 0 1 0
1 0 1 0 1
1 0 1 0 1 0
1 0 1 0 1 0 1
1 0 1 0 1 0 1 0
1 0 1 0 1 0 1 0 1
1 0 1 0 1 0 1 0 1 0
1-0 Number Pattern Logic:
If we see the above example patterns, We have number 1 at the first column and number  at the second column, and so on.
So we need to print the number 1 at the first column of every row. and print the number  at second column of every row, and again on third column we need to print 1 so on.
Which means we are printing the 1's each odd number column and 0's even number columns.
The main logic is to use the modulus operator ( % ). we will use ( j%2 )  to get the 1s and 0s. Here j is the inner loop iterator.
We will use two loops one outer loop and one inner loop
📢 Check out All Pattern Programs:
The 1-0 Number Pattern Programs:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
#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<=i; j++) Â Â Â Â Â Â Â Â printf(" %d", j%2); Â Â Â Â Â Â Â Â printf("\n"); Â Â } Â Â return 0; } |
Program Output:
Similar Number Patterns:
- Basic Number Pattern program.
- Triangle Number pattern using for loops.
- Number Pattern 3.
- C Program to print below pattern
- 5 4 3 2 1
5 4 3 2
5 4 3
5 4
5 - C Program to print below pattern.
- 1
2 3
4 5 6
7 8 9 10 - C Program to print Below Pattern,
- 5
4 5
3 4 5
2 3 4 5
1 2 3 4 5 - C Program to print below pattern.
- 1
 2 1
 3 2 1
 4 3 2 1
 5 4 3 2 1 - C Program to print below  pattern.
- 5 Â
5 4
5 4 3
5 4 3 2
5 4 3 2 1 Â
- C Program to print below Number pattern.
- 1
 2 2
 3 3 3
 4 4 4 4
 5 5 5 5 5
- C Program to print below Number pattern.
- Â 5
 4 4
 3 3 3
 2 2 2 2
 1 1 1 1 1
- CLICK here for the Below Pattern
- 5 5 5 5 5
 4 4 4 4
 3 3 3
 2 2
 1
- C Program to print below pattern
- 1 1 1 1 1
 2 2 2 2
 3 3 3
 4 4
 5
- C Program to print below pattern
- Â 1
 0 1
 0 1 0
 1 0 1 0
 1 0 1 0 1
Similar Star pattern programs :
- 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
- More Star Patterns
1 Response
[…] We have created the same pattern earlier but we used another method in that program. Please check that method at following link – Pattern 39: 1-0 Number Pattern in C Programming […]