#include<stdio.h>
#include<conio.h>
int main()
{
int
a,i,j,n,ascii[20],rem=0,var,count=0,numzeros=0;
int sum=0,x[20],z[20];
char str[20];
printf("enter the word
length\n");
scanf("%d",&n);
printf("enter the word : \t");
for(i=0;i<=n;i++)
{
scanf("%c",&str[i]);
}
for(i=1;i<=n;i++)
{
j=str[i];
ascii[i]=j;
}
for(i=1;i<=n;i++)
{
var=0;
sum=0;
a=ascii[i];
count=0;
while(a>1)
{
rem=a%2;
z[var]=rem;
if(rem==1)
{
count++;
}
a=a/2;
var++;
}
z[var]=a;
if(var<7)
{
numzeros=7-var;
for(j=0;j<numzeros;j++)
{
var++;
z[var]=0;
}
}
for(j=var;j>=0;j--)
{
printf("%d",z[j]);
}
if(a==1)
{
count++;
}
if(count%2==0)
{
printf("\t0\t");
}
else
{
printf("\t1\t");
}
}
getch();
}
No comments:
Write comments