C++ Online Compiler
Example: C++ program to convert decimal to binary using bitset
C
C++
C#
Java
Python
PHP
main.cpp
STDIN
Run
// C++ program to convert decimal to binary using bitset #include <iostream> #include <bitset> // Required for bitset using namespace std; // The main function of the program int main() { // Step-1 Declare variable int num; // Step-2 Input decimal number cout << "Enter a decimal number: "; cin >> num; // Step-3 Use bitset to convert and print binary cout << "Binary representation: " << bitset<32>(num) << endl; return 0; }
Output
Clear
ADVERTISEMENTS