EmbLogic's Blog

program to convert decimal to binary & octa & hexa

“1.Binary”;
2.Ocatal;
3.hexadecimal;

switch(choice)
{
case 1:
base=2;
case 2:
base=8;
case 3:
base=16;
“enter your no\n”;
convert(num,base);

convert(int num,int base)
{

int rem;
rem=num%base;
num/=base;
if(num>0)
convert(num,base);
if(rem<10)
printf(“%d”,rem);
else
printf(“%c”,rem-10 + ‘A’);

}

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>