Error Detection And Correction Program In C
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta write a program for hamming code generation for error detection and correction Discuss the workings and policies of this site About Us Learn hamming code for error detection and correction program in java more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us error detection and correction pdf Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you,
Error Detection And Correction In Computer Networks
helping each other. Join them; it only takes a minute: Sign up Hamming Code Error Detection up vote 2 down vote favorite 1 I have this code as given below for error checking by using hamming codes. I went through the algorithm on Wikipedia and also understood its working as described in the thread How does the error detection and correction ppt Hamming code work? But the code below uses some kind of sum of the parity bits in order to detect which bit is the error. Can someone please explain how exactly the sum can be used to detect the error bit? code: #include #include void main() { int i,a[4],c[3],r[7],clk[3],n,sum=0; printf("Enter data bits\n"); for(i=3;i>=0;i--) scanf("%d",&a[i]); printf("\n"); c[0]=(a[0]+a[1]+a[2])%2; c[1]=(a[1]+a[2]+a[3])%2; c[2]=(a[1]+a[0]+a[3])%2; printf("data bits after hamming code is\n"); for(i=3;i>=0;i--) printf("%d",a[i]); for(i=2;i>=0;i--) printf("%d",c[i]); printf("Enter recieved code\n"); for(i=0;i<7;i++) scanf("%d",&r[i]); clk[0]=(r[3]+r[1]+r[2]+r[6])%2; clk[1]=(r[0]+r[2]+r[1]+r[5])%2; clk[2]=(r[0]+r[2]+r[3]+r[4])%2; sum=4*clk[2]+2*clk[1]+1*clk[0]; if(sum==0) printf("\n u have recived coorrect code\n"); if(sum==1) { printf("Error in check bit 2\n"); printf("The correct code is"); r[6]=(r[6]+1)%2; for(i=0;i<7;i++) printf("%d",r[i]); } if(sum==2) { printf("Error in check bit 1\n"); printf("The correct code is"); r[5]=(r[5]+1)%2; for(i=0;i<7;i++) printf("%d",r[i]); } if(sum==3) { printf("\nError in data bit 1"); printf("The correct code is"); r[1]=(r[1]+1)%2; for(i=0;i<7;i++) printf("%d",r[i]); } if(sum==4) { printf("\n Error in chect bit 0"); printf("The correct code is"); r[4]=(r[4]+1)%2; for(i=0;i<7;i++) printf("%d",r[i]); } if(sum==5) { printf("\n Error in data bits 3"); printf("The correct code is"); r[3]=(r[3]+1)%2; for(i=0;i<7;i++) printf("%d",r[i]); } if(sum==6) { printf("Error in data bits 0"); printf("Th
1 of 1 New Topic/Question Reply 4 Replies - 6084 Views - Last Post: 07 November 2015 - 08:38 PM Rate Topic: #1 tpathak New D.I.C Head Reputation: 0 Posts: error detection and correction techniques 11 Joined: 28-June 14 Hamming Code - Error Detection & Correction Posted
Error Detection And Correction Hamming Distance
05 November 2015 - 11:39 PM This question builds on a few other posts. I understand if this is not
Error Detection And Correction Codes In Digital Electronics
relevant to most of the people on the internet but at this point, just like anyone else, I am stuck and cannot find the bug in logic. This question requires checking a http://stackoverflow.com/questions/10703643/hamming-code-error-detection specified hamming code for a single-bit error and report/correct the error. If the hamming code: 1000110 is entered, the hand-calculated error comes out to an error in bit 6 with the corrected code being 1100110. This code displays an error in bit 3 with the corrected code being 1000010. Any help is be greatly appreciated. Here is the program to do so: #include #include http://www.dreamincode.net/forums/topic/384134-hamming-code-error-detection-correction/ #include #include /** Initializing the global variables */ int MaxLength; int length; int parity; // Initialize the hamming string with a random or NULL memory address char *HammingString=NULL; /** Function to enter the values */ void EnterParameters(int *length, int *parity) { printf("Enter the maximum length: "); /** %d reads an integer to be stored in an int. This integer can be signed */ scanf("%d", length); printf("Enter the parity (0=even, 1=odd): "); /** %d reads an integer to be stored in an int. This integer can be signed */ scanf("%d", parity); } void CheckHamming(char *HammingString, int parity) { // Initializing the local variables i, j, k, start, length, ParityNumber int i, j, k, start, length, ParityNumber; printf("Enter the Hamming code: "); scanf("%s", HammingString); int ErrorBit = 0; // Initialize the error bit length = strlen(HammingString); // The strlen computes the length of a string up to, but not including the terminating null character length--; if (length > MaxLength) { printf("\n** Invalid Entry - Exceeds Maximum Code Length of %d\n\n", MaxLength); return; } ParityNumber = ceil(log(length)/log(2)); // The ceil function returns the smallest integer that is greater than or equal to
: Scanftree programs c implementation-of-hamming-code Algorithm ImplementationArrayConversionData structureDate and TimeDecision and LoopsDynamic AllocationFile HandlingFrequently Asked C programs in interviewGraphicsMathematical ProgramsMatrixMiscellaneousMy First http://scanftree.com/programs/c/implementation-of-hamming-code/ ProgramNetworkingNumber ProgramsPatternsPointerRecursionSearchingSeriesSortingStringSwapping Home Programs C Implementation of Hamming http://cboard.cprogramming.com/c-programming/76117-error-detection-correction.html Code Implementation of Hamming Code Levels of difficulty: Hard / perform operation: Algorithm Implementation C program #include #include void main() { int data[7],rec[7],i,c1,c2,c3,c; printf("this works for message of 4bits in size \nenter error detection message bit one by one: "); scanf("%d%d%d%d",&data[0],&data[1],&data[2],&data[4]); data[6]=data[0]^data[2]^data[4]; data[5]=data[0]^data[1]^data[4]; data[3]=data[0]^data[1]^data[2]; printf("\nthe encoded bits are given below: \n"); for (i=0;i<7;i++) { printf("%d ",data[i]); } printf("\nenter the received data bits one by one: "); for (i=0;i<7;i++) { scanf("%d",&rec[i]); } c1=rec[6]^rec[4]^rec[2]^rec[0]; c2=rec[5]^rec[4]^rec[1]^rec[0]; error detection and c3=rec[3]^rec[2]^rec[1]^rec[0]; c=c3*4+c2*2+c1 ; if(c==0) { printf("\ncongratulations there is no error: "); } else { printf("\nerron on the postion: %d\nthe correct message is \n",c); if(rec[7-c]==0) rec[7-c]=1; else rec[7-c]=0; for (i=0;i<7;i++) { printf("%d ",rec[i]); } } getch(); } Output Other Related Programs in c C code to Encrypt Message using PlayFair (Monarchy) Cipher C code to Encrypt & Decrypt Message using Transposition Cipher C code to Encrypt & Decrypt Message using Vernam Cipher C code to Encrypt & Decrypt Message using Substitution Cipher C code to implement RSA Algorithm(Encryption and Decryption) C Program to implement Huffman algorithm C Program to implement An activity selection problem C Program to implement Bellman-ford Algorithm C Program to solve Knapsack problem C Pr
Programming Boards C Programming Error Detection and Correction Getting started with C or C++ | C Tutorial | C++ Tutorial | C and C++ FAQ | Get a compiler | Fixes for common problems Thread: Error Detection and Correction Thread Tools Show Printable Version Email this Page… Subscribe to this Thread… Display Linear Mode Switch to Hybrid Mode Switch to Threaded Mode 02-22-2006 #1 daisy_polly View Profile View Forum Posts Registered User Join Date Feb 2006 Posts 21 Error Detection and Correction Hi, I am making an application for "The Hamming Code". I am having some problems I don't understand how to do this. The user can only put up to 5 characters. then the user will put the bit to flip.the output should look something like this: Code: Input a word to transmit: B Input a bit to flip: 12 Processing… - Transmitting character "B" with binary code 0100 0010 - The parity bits are: Bit 1 2 4 8 1 1 1 0 - The encoded array is: Bit 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1 1 0 0 1 0 0 0 0 0 1 0 0 0 0 Sending…. It is being corrupted by flipping bit 9. - The corrupted array is: Bit 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1 1 0 0 1 0 0 0 0 0 1 1 0 0 0 The corrupted character at destination is "C" The checksum for parity bits is: Bit 1 2 4 8 1 1 0 0 The corrected character is "B" I can read the chracter and convert it to binary but I am stuck afterwards. Code: #include char ascitobinary(); int main(void){ ascitobinary(); } char ascitobinary(){ char x ; int y; printf("Input a word to transmit: " ); scanf("%c",&x); for(y = 0; y < sizeof(char) * 15; y++) printf("%c ", ( x & (1 << y) ) ? '1' : '0' ); puts(""); return 0; } Thanks alot for help. Daisy 02-22-2006 #2 daisy_polly View Profile View Forum Posts Registered User Join Date Feb 2006 Posts 21 I don't need the solution