sivaramaiah  
 
  CRC 09/20/2017 9:51pm (UTC)
   
 

/*CRC PROGRAM */

#include <stdio.h>
#include <conio.h>
int g1[]={1,0,0,1,1};
int g2[]={1,1,0,0,0,0,0,0,0,1,1,1,1};
int g3[]={1,0,0,0,1,0,0,0,0,0,0,1,0,0,0,0,1};
int g4[]={1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1};
int f[100],g[20],r[2],df[100];
int ch,gl,n,i,j,k;
void main()
{
clrscr();
do{
    printf("\n 1.CRC");
    printf("\n 2.CRC-12");
    printf("\n 3.CRC-16");
 printf("\n 4.CRC-CCIT");
 printf("\n 5 .DEFAULT");
 printf("\n EXIT");
 printf("\n ENTER YOUR CHOICE");
 scanf("%d",&ch);
    switch(ch)
 {
   case 1 :for(i=0;i<5;i++)
            g[i]=g1[i];
      gl=5;
      break;
    case 2 :for(i=0;i<13;i++)
            g[i]=g2[i];
      gl=13;
            break;
    case 3 :for(i=0;i<17;i++)
            g[i]=g3[i];
      gl=17;
            break;
    case 4 :for(i=0;i<17;i++)
            g[i]=g4[i];
      gl=17;
            break;
    case 5 :printf("\n Enter the size of generator");
      scanf("%d",&gl);
      printf("\n Enter the generator bits");
      for(i=o;i<gl;i++)
      scanf("%d",&g[i]);
 }
 printf("\n Enter the frame size");
 scanf("%d",&n);
 if(n>=gl)
 {
  printf("\n enter the frame bits");
     for(i=0;i<n;i++)
  {
   scanf("%d",&f[i]);
   df[i]=f[i];
  }
  clrscr();
  printf("\n\n\t The entered frame is:");
  for(i=0;i<n;i++)
  printf("%d",f[i]);
  printf("\n\n\t The Polynomial is:");
  for(i=0;i<gl;i++)
  printf("%d",g[i]);
  for(i=0;i<gl-1;i++)
  f[n+i]=0;
  printf("\n\n\t\t\t ******STUFF*****");
  printf("\n\n\t After adding zeros the frame is:");
  for(i=0;i<(n+gl-1);i++)
  printf("%d",f[i]);
  division(f,g);
  for(i=0;i<(n+gl-1);i++)
  df[n+i]=r[i+1];
  printf("\n\n\t The Transmitted frame is:");
  for(i=0; i<(n+gl-1); i++)
  printf("%d",df[i]);
  printf("\n\n\t\t *****DESTUFF*****");
  printf("\n\n\t\t The Receiving frame is :");
  for(i=0;i<(n+gl-1);i++)
  printf("%d",df[i]);
  division(df,g);
  printf("\n\n\t There are no errors in the Received frame");
  }
  else
  printf("\n\n\t CRC is not possible");
  }while(ch<=5);
  getch();
  }
  division(int f[], int g[])
  {
    for(i=0;i<=(n-1);i++)
    {
      if((f[0]==1) && (g[0]==1))
   {
     for(j=0;j<gl;j++)
     {
       if(f[j]==g[j])
       f[j]=r[j]=0;
    else
       f[j]=r[j]=1;
   }
  }
  else
  {
    for(k=0;k<gl;k++)
        r[k]=f[k];
  }
  for(k=0;k<(n+gl-1);k++)
       f[k]=f[k+1];
 }
 printf("\n\n\t\t The Remainder is:");
 for(i=0;i<gl; i++)
 printf("%d",r[i]);
}

     
     

 
  Menu Items
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

  add
HOT TOPICS
MCA PROJECT DETAILS ------------------------------------- Jntu all Lab manuals ------------------------------------- Jntu Syllabus Books ------------------------------------- Paper presentations ------------------------------------- Seminars ------------------------------------- Campus Papers ------------------------------------- Competetive Exams GATE ------------------------------------- GRE ------------------------------------- TOEFL ------------------------------------- IELTS ------------------------------------- CAT ------------------------------------- GMAT ------------------------------------- Templates ------------------------------------- Students Resume Preparation tips ------------------------------------- Job zone(Interview questions) ------------------------------------- Google Adsence html code ------------------------------------- Web sites --------x--------------x-----------
  Advertisement
  Advertisement

 


-----------------------------
  Offline Messages
  Adds
  Visitors Information
Today, there have been 66440 visitors (187992 hits) on this page!
=> Do you also want a homepage for free? Then click here! <= --------------------------------------------------