Created
February 15, 2015 17:28
-
-
Save ahmedeshaan/fb59b11dc68071aa42ae to your computer and use it in GitHub Desktop.
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
//Recursive function | |
#include <stdio.h> | |
#include <stdlib.h> | |
int arg; | |
int newVar; | |
int modulus[10]; | |
int i=0; | |
void recusiveMain(arg){ | |
if(arg<=0){ | |
return 1; | |
}else { | |
modulus[i] = arg % 16; | |
//printf("%d \n",modulus[i]); | |
arg = arg / 16; | |
i++; | |
} | |
recusiveMain(arg); | |
} | |
void recusiveOutput(arg){ | |
switch(modulus[arg]) | |
{ | |
case 10: | |
printf("A"); | |
break; | |
case 11: | |
printf("B"); | |
break; | |
case 12: | |
printf("C"); | |
break; | |
case 13: | |
printf("D"); | |
break; | |
case 14: | |
printf("E"); | |
break; | |
case 15: | |
printf("F"); | |
break; | |
default: | |
printf("%d",modulus[arg]); | |
} | |
//printf("%d",modulus[arg]); | |
if(arg <= 0){ | |
return 1; | |
} | |
recusiveOutput(arg - 1); | |
} | |
int main() | |
{ int n=0; | |
printf("Insert you Decimal Number: "); | |
scanf("%d",&n); | |
if(n<0){ | |
n = -1*(n); | |
} | |
recusiveMain(n); | |
recusiveOutput(i-1); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment