// Include headers #include<stdio.h> #include<string.h> // length of the generator polynomial #define N strlen(gen_poly) // data to be transmitted and received char data[28]; // CRC value char check_value[28]; // generator polynomial char gen_poly[10]; // variables int data_length,i,j; // function that performs XOR operation void XOR(){ // if both bits are the same, the output is 0 // if the bits are different the output is 1 for(j = 1;j < N; j++) check_value[j] = (( check_value[j] == gen_poly[j])?'0':'1'); } // Function to check for errors on the receiver side void receiver(){ // get the received data printf("Enter the received data: "); scanf("%s", data); printf("\n-----------------------------\n"); printf("Data received: %s", data); // Cyclic Redundancy Check crc(); // Check if the remainder is zero to find the error ...
#include <stdio.h> int partition(int arr[], int low, int high) { int pivot = arr[low]; // Choosing the pivot element int i = low + 1; int j = high; while (i <= j) { while (i <= high && arr[i] <= pivot) { i++; } while (j >= low && arr[j] > pivot) { j--; } if (i < j) { int temp = arr[i]; arr[i] = arr[j]; arr[j] = temp; } } int temp = arr[low]; arr[low] = arr[j]; arr[j] = t...
Comments
Post a Comment