C# program to convert a decimal number into a binary number
All Answers
total answers (1)
Severity: 8192
Message: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated
Filename: libraries/Filtered_db.php
Line Number: 23
total answers (1)
Program:
The source code to convert a decimal number to the binary number is given below. The given program is compiled and executed successfully on Microsoft Visual Studio.
Output:
Explanation:
In the above program, we create a class Program that contains the Main() method, In the Main() method we read a decimal number from user input and then convert the decimal number into a corresponding binary number.
In the above code, we find the remainder of the decimal number after dividing by 2 and then concatenated into the string.
In the above code, we reversed the remainder string and covert the into the integer number and then print the result on the console screen.