Last active
January 11, 2020 03:50
-
-
Save krishnan793/ab91b91bdd1beb30637b to your computer and use it in GitHub Desktop.
Decimal to Hex Conversion using recursion.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
void Dec2Hex(int no){ | |
int hex=0; | |
if(!no) | |
return; | |
else { | |
hex=no%16; | |
Dec2Hex(no/16); | |
} | |
if(hex>9) | |
printf("%c",'A'+(hex-10)); | |
else | |
printf("%d",hex); | |
} | |
int main() | |
{ | |
int k=0; | |
printf("Enter no:"); | |
scanf("%d",&k); | |
Dec2Hex(k); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment