*/
Love this site? Hate it? Leave us some comments.
*/

View \HEXTDEC.C

Decimal to hexadecimal

Submitted By: sanjaycry
Rating: starstarstar (Rate It)


/*decimal to hexadecimal*/

#include<stdio.h>
#include<conio.h>
void main()
{
int n,i,a,m[20];
i=0;
clrscr();
printf("enter the no ");
scanf("%d",&n);
a=n%16;
while(n!=0)
{m[19-i]=a;
n=n/16;
a=n%16;
i+=1;}
printf("\n hex. eq. is ");
for(n=20-i;n<20;n++)
{switch(m[n])
{
case 10:
printf("A");
goto k;
case 11:
printf("B");
goto k;
case 12:
printf("C");
goto k;
case 13:
printf("D");
goto k;
case 14:
printf("E");
goto k;
case 15:
printf("F");
goto k;}
printf("%d",m[n]);
k:}
getch();
}

corner
© 1996-2008 CommunityHeaven LLC. All rights reserved. Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
North American business development: Nicolai Wadstrom. Publisher: Lars Hagelin.