Decimal To Octal In C
Let’s understand the idea involved in the programming of “Decimal To Octal Conversion In C“.
Given a decimal number as input, we need to write a program to convert the given decimal number into an equivalent octal number. i.e convert the number with base value 10 to base value 8. The base value of a number system determines the number of digits used to represent a numeric value. For example, the binary number system uses two digits 0 and 1, the octal number system uses 8 digits from 0-7 and the decimal number system uses 10 digits 0-9 to represent any numeric value.
Take a decimal number as input. Divide the input number by 8 and obtain its remainder and quotient. Store the remainder in the array. Repeat the process with the quotient obtained. Do this until the quotient becomes zero. Print the array in the reverse order to get the output.
Decimal To Octal In C
Output:
Explanation Of Code:
1. Take a decimal number as input and store it in the variable decimalnum.
2. Copy the variable decimalnum to the variable quotient.
3. Divide the variable quotient and obtain its remainder and quotient. Store the remainder in the array octalNumber and override the variable quotient with the quotient obtained.
4. Repeat step 3 until the quotient becomes zero.
5. When it becomes zero, print the array octalNumber in the reverse order to get the output.
Top Book Suggestion
The two books on C Programming Language that I Personally Recommend. I really loved reading these books. These books are listed for quality content, easy steps, and affordable price. You can get it from Amazon and Flipkart.
Check The Price On Amazon:
Check The Price On Flipkart:
Buy Premium Courses At Lowest Price. Become A Certified Developer Today!
Important C Programs
Basic C Programs
Programs On Number
String Programs
Array Programs
Sorting Programs
Pointer Programs
Star Pattern Programs
Number Pattern Programs
File Handling Programs
Programs On Recursion
Geometry Programs
Programs On Loop
Programs On Function
Switch Case Programs
If Else Programs
Bitwise Operator
Conditional Operator
Matrix Programs
Program On Calculation
Number System Conversion
All C programs