MY mENU


Tuesday 20 March 2012

Convert Decimal into Hexa Decimal

Convert Decimal into Hexa Decimal:

#include
#include
#include
void main()
{
Int x, y=30, z;
 clrscr();
  printf(“Enter the number:”);
    scanf(“%d”, &x);
       printf(“\n conversion of decimal to hexadecimal number\n”);
         for(;;)
          {
           if(x= =0)
             exit(1);
               z=x%16;
                   x=x/16;
                      gotoxy(y--,5);
           switch(z)
            {
              Case 10:
                Printf(“A”); Break;
             Case 11:
                Printf(“%c”, „B?); Break;
             Case 12:
                Printf(%c”, „C”); Break;
            Case 13:
                Printf(“D”);  Break;
           Case 14:
               Printf(“E”); Break;
           Case 15:
              Printf(“F”);
           Default:
              Printf(“%d”, z);
           }
        }
    getch();
}

Output:
Enter the number: 31
Conversion of decimal to Hexa decimal number 1F

No comments:

Post a Comment