I'm trying to convert hexadecimal values to Binary.
I've done Decimal values to Binary up to 32 bits in this way:
#include <stdio.h>
int showbits(int);/**************function*prototype******************************/
int main()
{
unsigned int num;
printf("enter the number.");
scanf("%d",&num);
printf("%d in binary is ",num);
printf("\n");
showbits(num);/*********************function*call********************************/
return 0;
}
showbits (int n)/******************function*definition****************************/
//*
{
int i,k,andmask;
for(i=31;i>=0;i--)
{
andmask = 1<<i;
k=n&andmask;
k==0?printf("0"):printf("1");
}
}
Now I wan't to add hexadecimal values in it.