mirror of
https://github.com/TheAlgorithms/C-Plus-Plus.git
synced 2026-05-11 19:17:21 +08:00
rename Others -> others (#648)
* rename Others -> temp * rename Others -> others
This commit is contained in:
25
others/Decimal To Binary.cpp
Normal file
25
others/Decimal To Binary.cpp
Normal file
@@ -0,0 +1,25 @@
|
||||
// This function convert decimal to binary number
|
||||
//
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
int main()
|
||||
{
|
||||
int number;
|
||||
cout << "Enter a number:";
|
||||
cin >> number;
|
||||
int remainder, binary = 0, var = 1;
|
||||
|
||||
do
|
||||
{
|
||||
remainder = number % 2;
|
||||
number = number / 2;
|
||||
binary = binary + (remainder * var);
|
||||
var = var * 10;
|
||||
|
||||
} while (number > 0);
|
||||
cout << "the binary is :";
|
||||
cout << binary;
|
||||
cout << endl;
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user