Error detection/correction C Objective: To check a Hamming code for a single-bit error, and to report and correct...

50.1K

Verified Solution

Question

Programming

Error detection/correction C

Objective:

To check a Hamming code for a single-bit error, and to reportand correct the error(if any)

Inputs:

1.The maximum length of a Hamming code

2.The parity of the check bits (even=0, odd=1)

3.The Hamming code as a binary string of 0’s and 1’s

Outputs:

1.The original parity bits (highest index to lowest index, leftto right)

2.The new parity bits (highest index to lowest index, left toright)

3.The bit-wise difference between the original parity bits andthe new parity bits

4.The erroneous bit (if any)

5.The corrected Hamming code (if there was an error)

Specification:

The program checks a Hamming code for a single-bit error basedon choosing from a menu of choices, where each choice calls theappropriate procedure, where the choices are:

1) Enter parameters

2)Check

Hamming code

3) Quit program

To use the Math library, use: “#include ” toaccess various functions, such as pow(base, exp), log(number),etc.To perform the XOR function, use the operator “^”.

To use the String library, use: “#include ” toaccess various functions, such as strlen(string) which returns aninteger representing the

length of a string of characters.

If necessary, include the flag “-lm” when you compile i.e. gccfilename.c–lm to be able to utilize the math library.

skeleton:

#include

#include

#include

#include

/* declare global var's including a dynamic array of charactersto store

the Hamming code,

original parity bits, and new parity bits*/

/*************************************************************/

void \"OPTION 1\"()

{

/* prompt for maximum length of hamming code and even/odd parity*/

printf(\"\nEnter the maximum length of the Hamming code: \");

/* allocate memory for Hamming code */

return;

}

/*************************************************************/

void \"OPTION 2\"()

{

/* declare local var's */

/* prompt for Hamming code */

/* calculate actual length of input Hamming code, number ofparity bits,

and highest parity bit */

/* Allocate memory for original and new parity bits */

/* Map parity bits within Hamming code to original parity bitarray */

/* Calculate new parity bits */

/* OUTER LOOP: FOR EACH PARITY BIT */

/* initialize parity bit to even/off parity */

/* MIDDLE LOOP: FOR EACH STATING BIT OF A CONSECUTIVE SEQUENCE*/

/* INNER LOOP: FOR EACH BIT OF A SEQUENCE TO BE CHECKED */

/* ignore original parity bit */

/* update new parity bit value based on Hamming code bit

checked */

} /* END INNER LOOP */

/* Map new parity bit value to new parity bit array */

} /* END OUTER LOOP */

/* Calculate error bit by XORing original and new parity bitsfrom

respective arrays, weighted properly */

/* Print original parity bits & new parity bits and bit-wisedifference */

/* If error, correct the bit and print which bit is in error andcorrected

Hamming code */

/* Else if no error, print message of no code bit error */

return;

}

/******************************* OPTIONAL************************/

void \"FREE MEMORY\"()

{

/* If daynamic array representing Hamming code is not NULL, freethe

memory */

return;

}

/*****************************************************************/

int main()

{

/* print menu of options, select user's choice, callappropriate

procedure, and loop until user quits */

return 1;

}

Please do not use abcdef as variable names

Answer & Explanation Solved by verified expert
4.5 Ratings (635 Votes)
include include include include Initializing the global variables int MaxLength int length int parity Initialize the hamming string with a random or NULL memory address char HammingStringNULL Function to enter the values void EnterParametersint length int parity printfEnter the maximum length d reads an integer to be stored in an int This integer can be signed scanfd length printfEnter the parity 0even 1odd d    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students