#include <math.h>
int convertDecimalToOctal(int decimalNumber);
int main(void){
int decimalNumber;
printf("Enter a decimal number: ");
scanf("%d", &decimalNumber);
printf("%d in decimal = %d in octal\n\n", decimalNumber, convertDecimalToOctal(decimalNumber));
return 0;
}
int convertDecimalToOctal(int decimalNumber){
int octalNumber = 0, i = 1;
while(decimalNumber != 0){
octalNumber += (decimalNumber % 8) * i;
decimalNumber /= 8;
i *= 10;
}
return octalNumber;
}
십진수를 입력: 78
8 진법에서 116
댓글 없음:
댓글 쓰기