How do i write a program that does this?

This is a discussion on How do i write a program that does this? within the C Programming forums, part of the General Programming Boards category; hi. i have this program i came across but i do not know how to do it. can someone help? ...

  1. #1
    Registered User
    Join Date
    Oct 2009
    Posts
    7

    How do i write a program that does this?

    hi. i have this program i came across but i do not know how to do it. can someone help?


    Program:

    Consider an n-bit binary number in the following form:
    bn−1bn−2bn−3...b0
    Each bi is a single bit in the n-bit binary number. Each bi 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.
    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. 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.

  2. #2
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Rondel, check out our homework policy, please.

    Basically, you need to show work on this assignment, and ask specific questions or post specific problems you're having.

    We're not a "homework center", kind of forum. Post up your work, and ask your questions.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Newbie needs help..
    By xpress urself in forum C++ Programming
    Replies: 3
    Last Post: 07-26-2007, 07:22 PM
  2. how could i write this program: cat < apa | wc | wc > bepa
    By strugglingman in forum C Programming
    Replies: 2
    Last Post: 04-26-2006, 04:40 PM
  3. Is there another way to write this program?
    By agentxx04 in forum C Programming
    Replies: 1
    Last Post: 11-23-2004, 08:28 PM
  4. Replies: 1
    Last Post: 10-13-2004, 12:15 PM
  5. Challenge to write a program
    By Twisted.alice in forum A Brief History of Cprogramming.com
    Replies: 40
    Last Post: 05-15-2003, 12:00 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21