Vertical Redundancy Check VRC

This program is for implementing Vertical Redundancy Check (VRC). This is a part of Mumbai University MCA Colleges Data Communication and Networking MCA Sem 4

#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);
}


Hope this Program is useful to you in some sense or other. Keep on following this blog for more Mumbai University MCA College Programs. Happy Programming and Studying.

No comments:

Post a Comment