NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

//CRC
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
int i, j, keylen, msglen;
char input[100], key[30], temp[30], quot[100], rem[30], key1[30];
clrscr();
printf("Enter Data: ");
gets(input);
printf("Enter Key: ");
gets(key);
keylen = strlen(key);
msglen = strlen(input);
strcpy(key1, key);
for (i = 0; i < keylen - 1; i++)
{
input[msglen + i] = '0';
}
for (i = 0; i < keylen; i++)
temp[i] = input[i];
for (i = 0; i < msglen; i++)
{
quot[i] = temp[0];
if (quot[i] == '0')
for (j = 0; j < keylen; j++)
key[j] = '0';
else
for (j = 0; j < keylen; j++)
key[j] = key1[j];
for (j = keylen - 1; j > 0; j--)
{
if (temp[j] == key[j])
rem[j - 1] = '0';
else
rem[j - 1] = '1';
}
rem[keylen - 1] = input[i + keylen];
strcpy(temp, rem);
}
strcpy(rem, temp);
printf("nQuotient is ");
for (i = 0; i < msglen; i++)
printf("%c", quot[i]);
printf("nRemainder is ");
for (i = 0; i < keylen - 1; i++)
printf("%c", rem[i]);
printf("nFinal data is: ");
for (i = 0; i < msglen; i++)
printf("%c", input[i]);
for (i = 0; i < keylen - 1; i++)
printf("%c", rem[i]);
getch();
}
// Bit stuffing
#include <stdio.h>
#include <string.h>

// Function for bit stuffing
void bitStuffing(int N, int arr[])
{
// Stores the stuffed array
int brr[30];

// Variables to traverse arrays
int i=0, j=0, k;

// Stores the count of consecutive ones
int count = 1;

// Loop to traverse in the range [0, N)
while (i < N)
{
// If the current bit is a set bit
if (arr[i] == 1)
{
// Insert into array brr[]
brr[j] = arr[i];

// Loop to check for next 5 bits
for (k = i + 1; arr[k] == 1 && k < N && count < 5; k++)
{
j++;
brr[j] = arr[k];
count++;

// If 5 consecutive set bits are found insert a 0 bit
if (count == 5)
{
j++;
brr[j] = 0;
}
i = k;
}
}

// Otherwise insert arr[i] into the array brr[]
else
{
brr[j] = arr[i];
}
i++;
j++;
}
// Print Answer
for (i = 0; i < j; i++)
{
printf("%d", brr[i]);
}
}
// Driver Code
int main()
{
int N = 6;
int arr[] = {1, 1, 1, 1, 1, 1};

bitStuffing(N, arr);

return 0;
}
//Byte stuffing
#include <stdio.h>
#include <string.h>
main()
{
char a[20], b[20];
int i, n, j;
char f, s;
printf("Enter the size of the frame : ");
scanf("%d", &n);
n = n * 2;
printf("nEnter the characters in frame : n");
for (i = 0; i < n; i++)
scanf("%c", &a[i]);
printf("n FRAME n ");
for (i = 0; i < n; i++)
printf("%c", a[i]);
j = 0;
for (i = 0; i < n; i++)
{
if (a[i] == 'f')
{
b[j] = 's';
j++;
b[j] = a[i];
}
else if (a[i] == 's')
{
b[j] = 's';
j++;
b[j] = a[i];
}
else
b[j] = a[i];

j++;
}
printf("n RESULT n");
printf("f");
for (i = 0; i < j; i++)
{
printf("n");
printf("%c", b[i]);
}
printf("nf");
}
//Checksum
#include <stdio.h>
#include <string.h>

int main()
{
char a[20], b[20];
char sum[20], complement[20];
int i, length;

printf("Enter first binary stringn");
scanf("%s", &a);
printf("Enter second binary stringn");
scanf("%s", &b);

if (strlen(a) == strlen(b))
{
length = strlen(a);
char carry = '0';

for (i = length - 1; i >= 0; i--)
{
if (a[i] == '0' && b[i] == '0' && carry == '0')
{
sum[i] = '0';
carry = '0';
}
else if (a[i] == '0' && b[i] == '0' && carry == '1')
{
sum[i] = '1';
carry = '0';
}
else if (a[i] == '0' && b[i] == '1' && carry == '0')
{
sum[i] = '1';
carry = '0';
}
else if (a[i] == '0' && b[i] == '1' && carry == '1')
{
sum[i] = '0';
carry = '1';
}
else if (a[i] == '1' && b[i] == '0' && carry == '0')
{
sum[i] = '1';
carry = '0';
}
else if (a[i] == '1' && b[i] == '0' && carry == '1')
{
sum[i] = '0';
carry = '1';
}
else if (a[i] == '1' && b[i] == '1' && carry == '0')
{
sum[i] = '0';
carry = '1';
}
else if (a[i] == '1' && b[i] == '1' && carry == '1')
{
sum[i] = '1';
carry = '1';
}
else{
break;
}
}

printf("nSum=%c%s", carry, sum);
for (i = 0; i < length; i++)
{
if (sum[i] == '0'){
complement[i] = '1';
}
else{

complement[i] = '0';
}
}

if (carry == '1'){
carry = '0';
}
else{
carry = '1';
}

printf("nChecksum=%c%sn", carry, complement);
printf("n");
}
else
{
printf("nWrong input strings");
}
}
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.