This program is for implementing Bit Stuffing .
#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();
}
#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();
}