Decimal to Binary, Octal and HEX converter

#include
#include
#define MAX 79
#define ESC 27
void main()
{
char res,r;
int i,k=0,y;
long j=0,l=0,o=0;
textcolor(15);
for(i=0;i<5000;i++)
cprintf(" ");
while(1)
{
clrscr();
printf("Enter Any Number To Be Converted : ");
scanf("%ld",&j);
l=j;
o=l;
k=0;
if(j>2145555550)
{
textcolor(4);
gotoxy(15,5);
cprintf("The Number Is Greater Than Range");
textcolor(15);
getch();
goto end;
}
else
{
gotoxy(1,6);
printf("Binary Equivalent:-");
y=MAX;
while(j>0)
{
k=j%2;
j=j/2;
gotoxy(y,6);
y--;
printf("%d",k);
}
gotoxy(1,8);
printf("Hexadecimal Equivalent:- ");
y=MAX;
while(l>0)
{
k=l%16;
l=l/16;
gotoxy(y,8);
y--;
if(k<=9)
{
printf("%d",k);
}
if(k==10)
{
printf("A");
}
if(k==11)
{
printf("B");
}
if(k==12)
{
printf("C");
}
if(k==13)
{
printf("D");
}
if(k==14)
{
printf("E");
}
if(k==15)
{
printf("F");
}
}
gotoxy(1,10);
printf("Octal Equivalent:- ");
y=MAX;
while(o>0)
{
k=o%8;
o=o/8;
gotoxy(y,10);
y--;
printf("%d",k);
}
}
gotoxy(15,25);
printf("Press Any Key To Continue , ESC To Exit");
res=getch();
if(res==ESC)
{
break;
}
}
end:
textcolor(7);
for(i=0;i<5000;i++)
cprintf(" ");
clrscr();
}

Related Links :

No comments:

Post a Comment


If you face any Problem in viewing code such as Incomplete "For Loops" or "Incorrect greater than or smaller" than equal to signs then please collect from My Web Site CLICK HERE


More Useful Topics...

 

History Of C..

In the beginning was Charles Babbage and his Analytical Engine, a machine
he built in 1822 that could be programmed to carry out different computations.
Move forward more than 100 years, where the U.S. government in
1942 used concepts from Babbage’s engine to create the ENIAC, the first
modern computer.
Meanwhile, over at the AT&T Bell Labs, in 1972 Dennis Ritchie was working
with two languages: B (for Bell) and BCPL (Basic Combined Programming
Language). Inspired by Pascal, Mr. Ritchie developed the C programming
language.

My 1st Program...


#include
#include
void main ()
{
clrscr ();
printf ("\n\n\n\n");
printf ("\t\t\t*******Pankaj *******\n");
printf ("\t\t\t********************************\n");
printf ("\t\t\t\"Life is Good...\"\n");
printf ("\t\t\t********************************");
getch ();
}

Next Step...


#include
#include

void main ()
{
clrscr ();
printf ("\n\n\n\n\n\n\n\n");
printf ("\t\t\t --------------------------- \n\n");

printf ("\t\t\t | IGCT, Info Computers, INDIA | \n\n");
printf ("\t\t\t --------------------------- ");

getch ();

}

Hits!!!