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:

Program Output:

Similar Number Patterns:

Similar Star pattern programs :

Venkatesh

Hi Guys, I am Venkatesh. I am a programmer and an Open Source enthusiast. I write about programming and technology on this blog.

You may also like...

1 Response

  1. […] 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 […]

Leave a Reply