Program in C to convert decimal to hexadecimal number

#include<stdio.h>
#include<conio.h>
#include<process.h>

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();
}


Post a Comment