Question: c++ Gray code is a binary number system where the two successive values differ in only one bit (reflected binary code). Write a program to
c++
Gray code is a binary number system where the two successive values differ in only one bit (reflected binary code). Write a program to generate all the Gray code values entered from a positive integer. The program will output all possible combinations up to nine variables, in table format, beginning at zero and flipping the right most bit. Use format shown below for output, with A, B, C, and so on representing the variables, 0 for false, 1 for true, and the correct sequence of combinations in logical order. Columns are separated by the "|" symbol, and the header is separated from the variables by a horizontal line. The input will be one integer, between 1 and 9, inclusive, representing the number of Boolean variables. Output to the screen the corresponding Gray code truth table representing all possible true/false combinations, as described above, and shown in the examples below. The program should loop continuously and terminate upon entering a sentinel value of -1.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
