

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is the octal equivalent of a decimal number in C#?
To get the octal equivalent of a decimal in C# −
Firstly, for the decimal value use a while loop and store the remainder in the array set for octal. Here we found the mod 8 of them in the array.
After that, divide the number by 8 −
while (dec != 0) { oct[i] = dec % 8; dec = dec / 8; i++; }
Let us see the complete code. Here, our decimal number is 12 −
Example
using System; namespace Demo { class Program { static void Main(string[] args) { int []oct = new int[50]; // decimal int dec = 12; int i = 0; while (dec != 0) { oct[i] = dec % 8; dec = dec / 8; i++; } for (int j = i - 1; j >= 0; j--) Console.Write(oct[j]); Console.ReadKey(); } } }
- Related Questions & Answers
- Convert octal number to decimal number in Java
- Java Program to convert octal number to decimal number
- C# program to convert decimal to Octal number
- Check if Decimal representation of an Octal number is divisible by 7 in Python
- What is 0 (zero) - A decimal literal or An octal literal in C++
- Java program to convert decimal number to octal value
- Java program to convert float decimal to Octal number
- Python program to convert float decimal to octal number
- Java Program to convert decimal integer to octal number
- How to Convert Decimal to Octal?
- What is Python equivalent of the ! operator?
- What is the C++ equivalent of sprintf?
- Convert decimal integer to octal in Java
- What is the equivalent of a VB module in C#?
- What is the equivalent of EXCEPT in MySQL?
Advertisements