Created
January 16, 2015 18:31
-
-
Save ahmedeshaan/920b4a12acd573cace1e 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
// Solution for: Take an integer(DECIMAL) input and convert it to Octal | |
int main() | |
{ | |
int octal_output[10]; | |
int i=1,j,n=-264; | |
// To avoid Negative Input | |
if(n<0) { | |
n = n +(-n*2); | |
} | |
while(n) { | |
// Put Moulous input in an array | |
binary_output[i] = n % 8; | |
// Devided nth number by 2 in round | |
n /= 8; | |
i++; | |
} | |
for(j=i-1; j>=1;j--) { | |
// Print the stored array input | |
printf("%d",octal_output[j]); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment