Decimal To Hexadecimal Conversion2

in Hindi - Decimal To Hexadecimal Conversion2



Click to Convert Decimal To Hexadecimal Number

Source Code :

RUN#include <stdio.h>

int main(){

int num1, q, rem, i, j=1, r;
char num2[100];

printf("Enter decimal number : ");
scanf("%d",&num1);

q = num1;

while(q != 0){
r = q % 16;

if( r < 10){
r = r + 48;
}
else{
r = r + 55;
num2[j++]= r;
q = q / 16;
}
}
printf("Hexadecimal Number : ",num1);
for(i = j -1 ;i> 0;i--){

printf("%c",num2[i]);
}
return 0;
}