title: Patterns in Binary Numbers
body: <blockquote>
  <p>Consider an n-bit binary number in the following form:</p>
  <p>b<sub>n−1</sub>b<sub>n−2</sub>b<sub>n−3</sub>...b<sub>0</sub></p>
  <p>Each b<sub>i</sub> is a single bit in the n-bit binary number. Each b<sub>i</sub> has one of two possible values: 0 or 1. An example of a 6-bit binary number is: 110011. Inside the computer, integers are represented as binary numbers. For example, the integer 43 can be represented by the 6-bit binary number: 101011. In this part, we will make use of an m-bit binary pattern that is constructed by taking the first m-bits of the repeating sequence 101010. . . . For example, for m equal to 3, the binary pattern is: 101. For m equal to 6, the binary pattern is: 101010. For m equal to 1, the binary pattern is: 1.</p>
  <p>Write a C program that reads integers n and m as input, and then prints out all n-bit binary numbers that contain the m-bit pattern. The binary numbers must be printed in ascending order. You are not allow to use strings, arrays or recursion for this question. Any program that uses strings, arrays or recursion will receive a grade of 0. Your program may assume that n will be a natural number less than or equal to 30, and that m will be a natural number less than or equal to n.</p>
  <p>A sample output for this program is:</p>
  <p>Enter an integer n: (5)<br />
  Enter an integer m: (3)<br />
  00101<br />
  01010<br />
  01011<br />
  01101<br />
  10100<br />
  10101<br />
  10110<br />
  10111<br />
  11010<br />
  11011<br />
  11101</p>
  </blockquote>
  <p>I'm a beginner in programming and I've gotten this assignment to do. I understand how the program is going to work but I'm not too sure how to go about it. Can anyone help me out and post a solution to this so I can run through it and see how it works. Thanks</p>