Your Ad Here

Wednesday, January 23, 2008

Cyclic Code

/* C Program For Implementation Of Cyclic Code */

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

void main()
{
int n,k,g[10],C[10],M[10],I,T[10];
int i,j,r;
clrscr();
printf("\t\t\t³ CYCLIC ENCODER ³\n");

printf("\n\nEnter The Value Of n and k\t:\n");
scanf("%d%d",&n,&k);
printf("\nEnter The Generator Polynomial Of Dergee %d",(n-k));
printf(" of the form 1+x+xý+x³+...\n");

for(i=0;i< n-k;i++)
scanf("%d",&g[i]);
printf("\nEnter Msg\n");
for(i=0;i< k;i++)
scanf("%d",&M[i]);
printf("\n\n");

for(i=0;i< n-k;i++)
{
T[i]=0;
}
for(i=0;i< k;i++)
{
I = (M[i] + T[n-k-1])%2;
C[0] = I;

for(j=1;j< n-k;j++)
{
if(g[j]==1)
C[j]=(I + T[j-1])%2;
else
C[j]=T[j-1];

}
for(r=0;r< n-k;r++)
{
T[r]=C[r];
}
}
printf("-----------------------------------------------------");
printf("\n³\tGenerated Cyclic code is\t: ");
for(i=0;i< k;i++)
printf("%d",M[i]);
printf(" ");
for(i=0;i< n-k;i++)
printf("%d",C[i]);
printf("\t\n-------------------------------------------------------");
getch();
}
/********************* OUTPUT *************************
³ CYCLIC ENCODER ³

Enter The Value Of n and k :
7
4

Enter The Generator Polynomial Of Dergee 3 of the form 1+x+xý+x³+...
1
1
0

Enter Msg
1
0
1
0


-------------------------------------------------------
Generated Cyclic code is : 1010 110
-------------------------------------------------------

*/

7 comments:

Anonymous said...

Good post.

graticcio@hotmail.com said...

need help in cyclic code, plz email me to talk

sainath said...

need decoding of cyclic codes ,plz mail me

Anonymous said...

need a decoder for cylic code.. i got the syndrome correct. need some help after that.. please email me at
somewhereond.earth@gmail.com

Anonymous said...

something wrong with your code

Krunal said...

Hi i am new bee to c , i just need your help in making c program in the following way

when i enter 4 as input the output should be in cyclic manner of 4*4
i.e.
1 2 3 4
12 13 14 5
11 16 15 6
10 9 8 7

see the output should be as above in cyclic manner of 4*4=16
in such a way i could enter any number and the output should be in cyclic manner of (n*n )

Please help me out , i am really stucked up

Anonymous said...

need a cyclic encoder....plz plz send it on my emailid cbse4200@yahoo.co.in

Your Ad Here