C++
Hamming code is a set of error-correction codes that can be used to detect and correct the errors that can occur when the data is moved or stored from the sender to the receiver. It is technique developed by R.W. Hamming for error correction.
Steps:
The r redundant bits placed at bit positions of powers of 2
Parity bits are calculated based upon the data bits and the redundant bits using the same rule as during generation of c1,c2 ,c3 ,c4 etc
The decimal equivalent of the parity bit's binary values is calculated. If it is 0, there is no error. Otherwise, the decimal value gives the bit position which has error. The bit is flipped to get the correct message.
2^r ≥ m + r + 1 =>> where, r = redundant bit, m = data bit
Here you can try it: