hi plz send me the logic for the binary convertio program
need the logc to binary conversion program
Collapse
X
-
Tags: None
-
Originally posted by allanarendra_re ddyhi plz send me the logic for the binary convertio program
I couldn't understand ur question, if u r asking the logic of printing the binary form of a decimal value then here is the logic.
unsigned short int i = 2, k = 0;
for(int j=0;j<16;j++)
{
k = i<<j;
printf("%d",k>> 15);
}
getch();
the above code will print the binary form of the value of i.Comment
-
#include<stdio. h>
#include<conio. h>
void main()
{
int num;
int i,,j,cnt=0,arr[16];
int k;
clrscr();
printf("\n enter the number:");
scanf("%d",&num );
for(i=0;num>0;i ++)
{
bin=num%2;
num=num/2;
arr[i]=bin;
cnt++;
}
printf('\n the number is :");
for(j=0;j<=cnt; j++)
{
k=(cnt-1)-j;
printf("%d',arr[k]);
}
getch();
}Comment
Comment