149. Design a function to print binary format of a given input number.
#include<stdio.h>
void
binary(int);
int
num;
void
main()
{
printf("Enter a number : ");
scanf("%d",&num);
binary(num);
printf("\n");
}
void
binary(int num)
{
int pos;
for(pos=31;pos>=0;pos--)
printf("%d",num>>pos&1);
}
Comments
Post a Comment