Question: Short program in C language Parity bit generation: Read an unsigned number and assume the last bit is used as the parity bit (bit 32).

Short program in C language

Parity bit generation:

Read an unsigned number and assume the last bit is used as the parity bit (bit 32).

Calculate the parity and set the last bit as either 0 or 1 (you may or the pattern with 1<<31) to make the last bit a 1.

Now you want to send the pattern to the sender we do this part in simulation.

You must generate a single error. This can be done using random numbers.

After you generate a single error, perform that tasks that the receiver will do. In other words, the receiver will calculate the parity for the received data and compare it with the received parity to decide if there is an error or not.

Explain the parity problem:

If sender decides to send an 8 bit pattern the sender adds an extra bit (called the parity bit). The parity bit is either decided to be even parity or odd paritylets assume we want to use even parity.

What even parity means: Count the number of 1s that is in the data value if it is even write 0 in the parity bit if the count is odd write a 1 in the parity bit. This makes the total number of 1s in the pattern sent an even number.

Receiver when it gets the pattern knows the last bit is the parity bit Receiver calculates the even parity for the data part. This calculated parity bit becomes either 1 or zero based on the number of received 1s in the data part.

Of course if there is no error, the value calculated must be the same as the parity bit received.

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!