C language— To check a Hamming code for a single-bit error, and to report and correct the error
$10-30 USD
Завершено
Опублікований about 8 years ago
$10-30 USD
Оплачується при отриманні
Objective:
To check a Hamming code for a single-bit error, and to report and correct the error (if
any).
Inputs:
The maximum length of a Hamming code
The parity of the check bits (even=0, odd=1)
The Hamming code
Outputs:
The erroneous bit (if any)
The corrected Hamming code (if there was an error)
Specification:
The program checks a Hamming code for a single-bit error based on choosing from a
menu of choices, where each choice calls the appropriate procedure, where the choices
are:
1) Enter parameters
2) Check Hamming code
3) Quit program
To use the Math library, use: “#include <math.h>” to access 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 <string.h>” to access various functions, such as
strlen(string) which returns an integer representing the length of a string of characters.
Skeleton code already posted, do not change the skeleton code
Output:
Error detection/correction:
---------------------------
1) Enter parameters
2) Check Hamming code
3) Quit
Enter selection: 1
Enter the maximum length: 12
Enter the parity (0=even, 1=odd): 0
Error detection/correction:
---------------------------
1) Enter parameters
2) Check Hamming code
3) Quit
Enter selection: 2
Enter the Hamming code: 1000110
There is an error in bit: 6
The corrected Hamming code is: 1100110
Error detection/correction:
---------------------------
1) Enter parameters
2) Check Hamming code
3) Quit
Enter selection: 1
Enter the maximum length: 21
Enter the parity (0=even, 1=odd): 1
Error detection/correction:
---------------------------
1) Enter parameters
2) Check Hamming code
3) Quit
Enter selection: 2
Enter the Hamming code: 1000110
There is an error in bit: 1
The corrected Hamming code is: 1000111
Error detection/correction:
---------------------------
1) Enter parameters
2) Check Hamming code
3) Quit
Enter selection: 2
Enter the Hamming code: 1000111
There is no bit error
Error detection/correction:
---------------------------
1) Enter parameters
2) Check Hamming code
3) Quit
Enter selection: 3
Hello,
Before you select a part time developer from here, take a look at fugacode.com. If you like what you see, contact us. That's all.
"Why hire freelancers? when you can hire professional developers for the same cost"
Regards,
FUGACODE Team