Bit Stuffing Data Communication


This program is for implementing Bit Stuffing . This is a part of Mumbai University MCA Colleges Data Communication and Networking MCA Sem 4

#include<stdio.h>
#include<conio.h>

void main()
{
            int a[20],b[20];
            int i,j,n,c;
            clrscr();
            c=0;
            printf("-------------BIT STUFFING----------");
            printf("\n\nHow many Numbers do you want to insert : ");
            scanf("%d",&n);
            printf("\n\nEnter data : ");
            for(i=0;i<n;i++)
            {
                        scanf("%d",&a[i]);
            }

            printf("\n\nArray : \n\n");
            for(i=0;i<n;i++)
            {
                        printf("%d ",a[i]);
            }
            j=0;
            for(i=0;i<n;i++)
            {

                        if(a[i]==1)
                        {
                                    c=c+1;
                                    if(c==5)
                                    {
                                                b[j]=a[i];
                                                j++;
                                                b[j]=0;
                                                j++;
                                                c=0;

                                    }
                                    else
                                    {
                                                b[j]=a[i];
                                                j++;
                                    }

                        }
                        else
                                    {
                                                c=0;
                                                b[j]=a[i];
                                                j++;
                                    }
            }
            printf("\n\nStuffed Array : \n\n");
            for(i=0;i<j;i++)
            {
                        printf("%d ",b[i]);
            }
            getch();
}


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