You are on page 1of 5

PRACTICALNO: 4

Date:

Program:

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

void main()
{
int i,a[10],h[6][9],f[8],b[4]={1,0,0,0},e[4],p[4],c,n,j,k,l,m,x,y;
char d[10]="harry";
clrscr();
l=0;
for(i=0;i<=5;i++)
{
a[i]=d[i];
printf("%c\t%x\t",d[i],a[i]);
j=7;
k=a[i];
do
{
c=k/2;
n=k%2;
f[j]=n;
j--;
k=c;
}while(c!=1);
f[j]=1;
j--;
do
{
f[j]=0;
j--;
}while(j>0);
for(m=0;m<=7;m++)
{
h[i][m]=f[m];
printf("%d",f[m]);
}
printf("\n");
}
c=0;
for(i=0;i<6;i++)
{
c=0;
l=0;
for(j=0;j<8;j++)
{
l=h[i][j];
printf("%d",h[i][j]);
if(l==1)
{
c++;
}
}
if ( (c%2) !=0 )
{
h[i][j]=1;
printf("\t%d",h[i][j]);
}
else
{
h[i][j]=0;
printf("\t%d",h[i][j]);
}
printf("\n");
}
for(i=0;i<8;i++)
{
x=0;
y=0;
for(j=0;j<6;j++)
{
y=h[j][i];
if(y==1)
{
x++;
}
}
if ( (x%2) !=0 )
{
h[j][i]=1;
}
else
{
h[j][i]=0;
}

}
for(i=0;i<8;i++)
{
x=0;
y=0;
for(j=0;j<6;j++)
{
y=h[j][i];
if(y==1)
{
x++;
}
}
if ( (x%2) !=0 )
{
h[j][i]=1;
}
else
{
h[j][i]=0;
}
}
printf("\n");
for(i=0;i<7;i++)
{
for(j=0;j<8;j++)
{
if (i==6)
{
printf("%d",h[i][j]);
}
}
}
getch ();
}

OUTPUT:
CONCLUSION:

You might also like