Question: Create a C++ program to add either even or odd parity, no parity as default, to a byte. Next randomly flip one bit and detect
Create a C++ program to add either even or odd parity, no parity as default, to a byte. Next randomly flip one bit and detect that there is an parity error and report. Submit source code.
Algorithm to create and add parity bit:
integer array[8]
integer even = 0, odd = 0; integer bitcount=0;
for (intgere i=0; i <6; i++) { if (array[i] == 1) { increment bitcount } }
if (bitcount modulus 2 equal zero){ even = 0 odd = 1 } else { even = 1 odd = 0 }
if (parityType is even) array[7] = even else if (parityType is odd) array[7] = odd
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
