Question: Write a C or C++ program that require user to input only binary numbers. The program have to detect any four consecutive 0s in any

Write a C or C++ program that require user to input only binary numbers. The program have to detect any four consecutive 0’s in any space, after that the program have to automatically replace or substitute these four consecutive 0’s by one of these pattern (B00V) or (000V). To choose which one of these patterns to use depending on the previous digit that came before the consecutive 0’s. If a digit number 1 odd came before the consecutive 0’s, 000V pattern will be chosen. If two even digits like 11 came before the consecutive 0’s, b00v pattern will be chosen. To determine when it became odd or even like this example.

11 (we have two number of one so it is even).

111 (we have three numbers of one so it is odd). Note that the 1’s bits polarity always be opposite from the previous one. Example if the user input 1111 the output should be +-+-(we assume that it start with +).

In case of B00V, that the polarity of B must be the same as V (that is, –00– or +00+). To make the polarity of B00V to be like -00- or +00+ depending on the previous bits that came before the four consecutive 0’s.The polarity of B00V should be opposite of the last previous bit. The polarity of 000V should be the same as the last previous bit.

Example of the program:

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

The question is complete Lets proceed with the solution To address this problem you can write a C program that processes a binary input string detects ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Document Format (2 attachments)

PDF file Icon

6098ab1a90174_29084.pdf

180 KBs PDF File

Word file Icon

6098ab1a90174_29084.docx

120 KBs Word File

Students Have Also Explored These Related Programming Questions!