Encode
The following code will be useful to encode the binary data
public static void Main()
{
int a[]={1,1,0,1};//binary data or message bits
int p1,p2,p3;//parity bits
p1=a[3]^a[1]^a[0];
p2=a[3]^a[2]^a[1];
p3=a[2]^a[1]^a[0];
for(int i=0;i<=6;i++)
int b[i]=a[i];
if(i==4)
{
b[4]=p1;
}
if(i==5)
{
b[5]=p2;
}
if(i==6)
{
b[6]=p3;
}
for(i=0;i<=6;i++)
{
printf("%d",b[i]);
}
Finally we will get the encoded output as 1101100 that is the parity bits are appended along with the message bits , encoding is one of the process and a form of encryption used for data transmission process in communication