Skip to content

Instantly share code, notes, and snippets.

@krishnan793
Last active January 11, 2020 03:50
Show Gist options
  • Save krishnan793/ab91b91bdd1beb30637b to your computer and use it in GitHub Desktop.
Save krishnan793/ab91b91bdd1beb30637b to your computer and use it in GitHub Desktop.
Decimal to Hex Conversion using recursion.
#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