Input a number ( less than 32767 ) and print the binary equivalent of that number.
#include <stdio.h>
#include <conio.h>
void main ( )
{
int md[10], no, c = 0, d =0;
clrscr ( );
printf ("\n\t\t Enter a number......:"); scanf ("%d", & no);
while ( no > 0 )
{
md[c] = no % 2;
no = no / 2;
c++;
}
printf ("\n\n\n\t\t The Binary numbers = ");
for ( d = c - 1; d >= 0; d-- )
{
printf ("%d ", md[d]);
}
getch ( );
}
Click here to contact us
No comments:
Post a Comment