Friday, January 6, 2012

Conversion of TEXT to BINARY

#include<stdio.h>
#include<string.h>
void main()
{
int d,i=0,j=0,bin[8]={0};
char list[20],c;
clrscr();
printf("enter text press enter at last-");
while((c=getchar())!='n')
list[i++]=c;

i=0;


while(i<strlen(list))
{
d=list[i];
j=0;
while(d>=1)
{
if(d==1)
{
bin[j]=1;
break;
}
bin[j]=d%2;
d=d/2;
j++;
}


for(j=7;j>=0;j--)
printf("%d",bin[j]);
printf("n");
i++;
}


getch();
}

1 comment:

  1. i hope no1 sees this, i have no time to edit it a understandable way
    i'll do it if i get time for it.

    ReplyDelete