Program:
|
#include<stdio.h>
#include<string.h>
#include<conio.h>
#define MAX 5
#define BINARY 8
void converted(int r,int result[])
{
int i = 7;
int rem;
for(i = 7;i>=0;i--)
{
rem = r%2;
r = r/2;
result[i] = rem;
}
}
void main()
{
char c,store[MAX];
int i,j,r,a,result[BINARY];
clrscr();
printf("\nEnter:");
scanf("%s",store);
a=strlen(store);
for(i=0;i<a;i++)
{
r=store[i];
converted(r,result);
for(j=0;j<BINARY;j++)
{
printf("%d",result[j]);
}
printf(" ");
}
getch();
}
No comments:
Post a Comment