Last active
August 29, 2015 14:15
-
-
Save ahmedeshaan/2d5414fbdd6424f3f1d6 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
//Decimal To Binary Recursive function | |
#include <stdio.h> | |
#include <stdlib.h> | |
int arg; | |
int newVar; | |
int modulus[10]; | |
int i=0; | |
void myFunction(arg){ | |
if(arg<=0){ | |
return 1; | |
}else { | |
modulus[i] = arg % 2; | |
//printf("%d \n",modulus[i]); | |
arg = arg / 2; | |
i++; | |
} | |
myFunction(arg); | |
} | |
void yourFunction(arg){ | |
printf("%d",modulus[arg]); | |
if(arg <= 0){ | |
return 1; | |
} | |
yourFunction(arg - 1); | |
} | |
int main() | |
{ int n=0; | |
printf("Insert you Decimal Number: "); | |
scanf("%d",&n); | |
if(n<0){ | |
n = -1*(n); | |
} | |
myFunction(n); | |
yourFunction(i-1); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment