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 are a 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

1 Expert Approved Answer
Step: 1 Unlock 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

Students Have Also Explored These Related Databases Questions!