Step-by-step Algorithm:
//C program to Convert Octal to Decimal. #include <stdio.h> int main() { int octalNum, decimalNum = 0, base = 1, remainder; printf("Enter an octal number: "); scanf("%d", &octalNum); // Convert octal to decimal while (octalNum != 0) { // Extract the last digit remainder = octalNum % 10; // Multiply digit with base and add to decimalNum decimalNum += remainder * base; // Remove the last digit octalNum /= 10; // Increase base by a power of 8 for next digit base *= 8; } printf("Decimal equivalent: %d\n", decimalNum); return 0; }
Enter an octal number: 127
Decimal equivalent: 87

Trends is an amazing magazine Blogger theme that is easy to customize and change to fit your needs.