0% found this document useful (0 votes)
54 views8 pages

Practical 6

This document describes programs that demonstrate error detection using vertical redundancy check (VRC) and longitudinal redundancy check (LRC). It includes the code for a VRC program that takes in two characters, converts them to binary, calculates the parity bit, and displays the original and received bits. It also includes code for an LRC program that similarly takes in characters, finds the parity bit across the rows, and displays the original, received, and parity bits. The document provides background on C programming and error detection methods needed to understand the programs.

Uploaded by

poojan thakkar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
54 views8 pages

Practical 6

This document describes programs that demonstrate error detection using vertical redundancy check (VRC) and longitudinal redundancy check (LRC). It includes the code for a VRC program that takes in two characters, converts them to binary, calculates the parity bit, and displays the original and received bits. It also includes code for an LRC program that similarly takes in characters, finds the parity bit across the rows, and displays the original, received, and parity bits. The document provides background on C programming and error detection methods needed to understand the programs.

Uploaded by

poojan thakkar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

PRACTICAL-6

Aim : Write a program which demonstrates the concept of Error Detection


and correction methods like VRC and LRC .
Hardware Requirement :- Computer or Laptop for run program

Software Requirement:- Turbo c++

Knowledge Requirment :- knowledge require about c programming and how to error


correction and detection method used like VRC and LRC .

 VRC Program :

#include<stdio.h>
#include<conio.h>
int binary(int);
void parity(int[]);

int arr[9],arr1[9];
char chr;
int temp,temp1,i;
void main()
{ char chr1;
clrscr();
printf("Enter Data :");
scanf("%c %c",&chr,&chr1);
temp=chr;
binary(temp);
printf("\nAscii value is : %d\n",temp);
printf("\nBinary Form : ");
for(i=0;i<8;i++)
{
arr1[i]=arr[i];
printf("%d ",arr[i]);
}
printf("\n");
parity(arr);
temp1=chr1;
binary(temp1);
printf("\n\nAscii value is : %d\n",temp1);
printf("\nBinary Form : ");
for(i=0;i<8;i++)
{
printf("%d ",arr[i]);
}
parity(arr);
getch();
}
void parity(int a[])
{
int count;
count=0;
for(i=0;i<8;i++)
{
if(a[i]==1)
count++;
}
if(count%2==0)
a[8]=0;
else
a[8]=1;
count=0;
printf(“Receiver Side :\n”);
printf("\n\nVRC : \n");
for(i=0;i<9;i++)
{
if(i==8)
printf(" | ");
printf("%d ",a[i]);
}
}
int binary(int x)
{
int rem;
int ctr=0,i=1;
do
{
rem=x%2;
arr[i]=rem;
if(rem==1)
{
ctr++;
}
x=x/2;
i++;
}
while(x!=0);
if(ctr%2==0)
{
arr[0]=0;
}
else
{
arr[0]=1;
}
return(0);
}

 LRC Program :

#include<stdio.h>
#include<conio.h>
int binary(int);
void parity(int [],int []);

int arr[8],arr1[8],parityarr[8];
char chr;
int go,temp,temp1,i;
void main()
{ char chr1;
clrscr();
go=0;
Sender:
if(go==0)
printf("Enter Data : \n");
printf("\nEnter a character : ");
scanf("%c %c",&chr,&chr1);
temp=chr;
binary(temp);
printf("\n\nAscii value is : %d\n",temp);
printf("\nBinary Form : ");
for(i=7;i>=0;i--)
{
arr1[i]=arr[i];
printf("%d ",arr[i]);
}
printf("\n");

temp1=chr1;
binary(temp1);
printf("\n\nAscii value is : %d\n",temp1);
printf("\nBinary Form : ");
for(i=7;i>=0;i--)
{
printf("%d ",arr[i]);
}
parity(arr,arr1);
for(i=7;i>=0;i--)
{
arr[i]=0;
arr1[i]=0;
}
getch();
}
void parity(int arr[],int arr1[])
{
printf(“Receiver Side :\n”);
printf("\n\nLRC :\n");
for(i=7;i>=0;i--)
{
printf("%d ",arr[i]);
}
printf("\n");
for(i=7;i>=0;i--)
{
printf("%d ",arr1[i]);
}
printf("\n---------------------\n");
for(i=0;i<8;i++)
{
if(arr[i]==0 && arr1[i]==0 || arr[i]==1 && arr1[i]==1)
{
parityarr[i]=0;
}
else if(arr[i]==1 && arr1[i]==0 || arr[i]==0 && arr1[i]==1)
{
parityarr[i]=1;
}
}
for(i=7;i>=0;i--)
{
printf("%d ",parityarr[i]);
}
}
int binary(int x)
{
int rem;
int ctr=0,i=1;
do
{
rem=x%2;
arr[i]=rem;
if(rem==1)
{
ctr++;
}
x=x/2;
i++;
}
while(x!=0);
if(ctr%2==0)
{
arr[0]=0;
}
else
{
arr[0]=1;
}
return(0);
}
 Questions and Answers
1. Write Full form of LRC and VLC .
 LRC : Longitudinal Redundancy Check
 VRC: Vertical Redundancy Check

 Conclusion
 In this Practical we know about how to detect and correct error throught the
LRC and VRC method.

You might also like