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