Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In C: Write a function void paritize (void *p, unsigned int num bytes); that accepts a void pointer that points to an array of bytes

In C: Write a function void paritize (void *p, unsigned int num bytes); that accepts a void pointer that points to an array of bytes in memory along with the number of bytes the pointer points to, and (1) for each byte, the function computes its parity bit. For a given byte, the parity bit p is 1 if the number of 1s in the first 7 bits (i.e., if a byte were b7b6b5b4b3b2b1b0 then b6 through b0 are the first 7 bits) is odd, or 0 if the number of 1s is even. Then (2) the function replaces the most significant bit (i.e., bit b7) in the byte with the parity bit.

Sample input and expected output:

byte-array that p points to (before calling paritize) in Hex:deadbeef num bytes: 4 byte-array that p points to (after calling paritize) in Hex: de2dbe6f

byte-array that p points to (before calling paritize) in Hex:0 num bytes: 1 byte-array that p points to (after calling paritize) in Hex: 0

byte-array that p points to (before calling paritize) in Hex:1 num bytes: 1 byte-array that p points to (after calling paritize) in Hex: 81

byte-array that p points to (before calling paritize) in Hex:12345678deadc0de num bytes: 8 byte-array that p points to (after calling paritize) in Hex: 12b45678de2dc0de

To test:

int main{

unsigned long x = 0x12345678deadc0de;

paritize(&x, sizeof(x));

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Focus On Geodatabases In ArcGIS Pro

Authors: David W. Allen

1st Edition

1589484452, 978-1589484450

More Books

Students also viewed these Databases questions

Question

What is meant by the phrase beat the market?

Answered: 1 week ago

Question

1.The difference between climate and weather?

Answered: 1 week ago

Question

1. What is Fog ?

Answered: 1 week ago

Question

How water vapour forms ?

Answered: 1 week ago

Question

What is Entrepreneur?

Answered: 1 week ago

Question

Which period is known as the chalolithic age ?

Answered: 1 week ago

Question

How many Tables Will Base HCMSs typically have? Why?

Answered: 1 week ago

Question

What is the process of normalization?

Answered: 1 week ago