Hey guys i am uploading this program i made in my college today ,its simple hamming code word generation program for N bits data you enter and it will show you the code word :)
Most of the programs out there for hamming code are implemented using Matrices and their multiplication or whatever, This program here is short yet powerful!
Hamming code is a popular error detection and error correction method in data communication. Hamming code can only detect 2 bit error and correct a single bit error which means it is unable to correct burst errors if may occur while transmission of data.
Please Like and share if helped for you , thanks
Enter any no of bits and get its hamming code !
This code is for even piraty, you may edit it and convert it to generate odd piraty .
C++ Implementation :
#include <iostream> #include <stdlib.h> #include <stdio.h> #include <math.h> using namespace std; int main () { int a, b, c[30], d, r = 0, d1; //Max bits here i kept is 30 cout << " Enter the No of Data Bits you want to Enter : "; cin >> a; while (a + r + 1 > pow (2, r)) { r++; } cout << "No of data bits to be added " << r << " : Total Bits :" << a + r << endl; cout << " Enter the Data Bits One by One :" << endl; for (int i = 1; i <= a; ++i) cin >> c[i]; cout << endl << " Data bits entered : "; for (int i = 1; i <= a; ++i) cout << c[i] << " "; cout << endl; int data[a + r]; d = 0; d1 = 1; for (int i = 1; i <= a + r; ++i) { if ((i) == pow (2, d)) { data[i] = 0; ++d; } else { data[i] = c[d1]; ++d1; } } cout << " Data Bits are Encoded with Parity bits(0): "; for (int i = 1; i <= a + r; ++i) cout << data[i] << " "; d1 = 0; int min, max = 0, parity, s, j; /*Parity Bit Calculation */ for (int i = 1; i <= a + r; i = pow (2, d1)) { ++d1; parity = 0; j = i; s = i; min = 1; max = i; for (j; j <= a + r;) { for (s = j; max >= min && s <= a + r; ++min, ++s) { if (data[s] == 1) parity++; } j = s + i; min = 1; } if (parity % 2 == 0) // Even Parity { data[i] = 0; } else { data[i] = 1; } } cout << endl << " Hamming codeword bits for even parity are : "; for (int i = 1; i <= a + r; ++i) cout << data[i] << " "; cout << endl << endl; } //End
Comment below if you have any queries related to above hamming code program in C++.
OutPut :
Have a great day !
Your Affiliate Money Making Machine is ready -
ReplyDeleteAnd making profit with it is as easy as 1--2--3!
Here is how it all works...
STEP 1. Choose affiliate products you want to promote
STEP 2. Add some push button traffic (it LITERALLY takes JUST 2 minutes)
STEP 3. See how the system grow your list and up-sell your affiliate products on it's own!
Do you want to start making profits??
You can test-drive the system for yourself risk free...
How to login into the casino in 2021
ReplyDeleteHere is how to do this: Step 1. apr casino Go to poormansguidetocasinogambling the website. · Click on the “Login” link หารายได้เสริม on the right-hand side. · Click on 출장샵 the “Login” button to enter a live chat number. · Enter the https://vannienailor4166blog.blogspot.com/