main() { long int dec; int i,hex,a=0,j,b=0,n; char ans[10],ans1[10]; clrscr(); printf("\n\n\n\t\tThis program will help you to evaluate the Hexadecimal"); printf("\n\t\t Equivalent of the given decimal number."); printf("\n\n\n\t\t\t Enter the decimal number : "); scanf("%ld",&dec); i=0; while(dec!=0) { hex=dec%16; if((hex>=10)&&(hex<=15)) { if(hex==10) ans[a]='A'; if(hex==11) ans[a]='B'; if(hex==12) ans[a]='C'; if(hex==13) ans[a]='D'; if(hex==14) ans[a]='E'; if(hex==15) ans[a]='F'; } if((hex>=0)&&(hex<=9)) { if(hex==0) ans[a]='0'; if(hex==1) ans[a]='1'; if(hex==2) ans[a]='2'; if(hex==3) ans[a]='3'; if(hex==4) ans[a]='4'; if(hex==5) ans[a]='5'; if(hex==6) ans[a]='6'; if(hex==7) ans[a]='7'; if(hex==8) ans[a]='8'; if(hex==9) ans[a]='9'; } dec=dec/16; i++; a++; } ans[a]='\0'; printf("\n\n\t\t\t\t - A N S W E R - "); printf("\n\n\n\t\t The hexadecimal Equivalent of the given "); printf("\n\t\t decimal number is : \n\n\t\t\t\t\t-> "); b=0; a--; n=a; for(b=0;b<=n;b++) { ans1[b]=ans[a]; a--; } ans1[b]='\0'; puts(ans1); getch(); }