convert decimal to binary in c++
C++
// C++ program to convert a decimal
// number to binary number
#include <iostream>
using namespace std;
// function to convert decimal to binary
void decToBinary(int n)
{
// array to store binary number
int binaryNum[32];
// counter for binary array
int i = 0;
while (n > 0) {
// storing remainder in binary array
binaryNum[i] = n % 2;
n = n / 2;
i++;
}
// printing binary array in reverse order
for (int j = i - 1; j >= 0; j--)
cout << binaryNum[j];
}
// Driver program to test above function
int main()
{
int n = 17;
decToBinary(n);
return 0;
}
Also in C++:
- Title
- rand c++
- Category
- C++
- Title
- dijkstra in c++
- Category
- C++
- Title
- friend function in c++
- Category
- C++
- Title
- heap in cpp stl
- Category
- C++
- Title
- shortest path with bfs in c++
- Category
- C++
- Title
- c++ wait for user input
- Category
- C++
- Title
- c++ string to integer without stoi
- Category
- C++
- Title
- c++ function return array
- Category
- C++
- Title
- rick astley - never gonna give you up
- Category
- C++
- Title
- check for bst
- Category
- C++
- Title
- minimum swaps to sort an array
- Category
- C++
- Title
- c++ files
- Category
- C++
- Title
- c++ while loop code
- Category
- C++
- Title
- delay millis arduino
- Category
- C++
- Title
- passing array to function in c++
- Category
- C++
- Title
- empty string c++ value
- Category
- C++
- Title
- how to use max_element in c++ with vector
- Category
- C++
- Title
- insert function in c++ vector
- Category
- C++
- Title
- opencv compile c++
- Category
- C++
- Title
- c++ cli convert string to string^
- Category
- C++
- Title
- max three values c++
- Category
- C++
- Title
- placement new c++
- Category
- C++
- Title
- fast input output in c++
- Category
- C++
- Title
- How to check if a triangular cycle exists in a graph
- Category
- C++
- Title
- repeating character in c++
- Category
- C++
- Title
- recursion in cpp with reference
- Category
- C++
- Title
- string comparison in c++
- Category
- C++
- Title
- length of string in c++
- Category
- C++
- Title
- c++ sql
- Category
- C++
- Title
- c++ string to int
- Category
- C++
- Title
- create a bitset of 1024 bits,
- Category
- C++
- Title
- properties of a set c++
- Category
- C++
- Title
- getting a random letter in c++
- Category
- C++
- Title
- sqrt in c++
- Category
- C++
- Title
- how to find the mode of a vector c++
- Category
- C++
- Title
- regexp_like oracle c++
- Category
- C++
- Title
- primos menores que
- Category
- C++
- Title
- for c++
- Category
- C++
- Title
- object reference not set to an instance of an object c#
- Category
- C++
- Title
- unordered_set in c++ and ordered set diff
- Category
- C++
- Title
- c++ remove element from vector
- Category
- C++
- Title
- calculate factorial
- Category
- C++
- Title
- c++ char print width
- Category
- C++
- Title
- max heap c++ stl;
- Category
- C++
- Title
- remove element by index from vector c++
- Category
- C++
- Title
- c++ set add element
- Category
- C++
- Title
- c++ class inheritance
- Category
- C++
- Title
- variabili in c++
- Category
- C++
- Title
- euler phi gfg
- Category
- C++
- Title
- how do for loops on c++
- Category
- C++
- Title
- level order traversal
- Category
- C++
- Title
- traverse map c++
- Category
- C++
- Title
- pass ss tream as parameter c++
- Category
- C++
- Title
- c++ std::copy to cout
- Category
- C++
- Title
- map arduino
- Category
- C++
- Title
- c++ menu selection with arrow keys
- Category
- C++
- Title
- c++ overloaded == operator
- Category
- C++
- Title
- Runtime Error: Runtime ErrorFloating-point exception (SIGFPE
- Category
- C++
- Title
- c++ delete dynamically allocated array
- Category
- C++
- Title
- switch statement c++
- Category
- C++
- Title
- c++ how to loop through a vector but not the last element
- Category
- C++
- Title
- prefix sum array
- Category
- C++
- Title
- reference function in c++
- Category
- C++
- Title
- switch c++
- Category
- C++
- Title
- mysqli connect
- Category
- C++
- Title
- c++ modulo make it give only positive numbers
- Category
- C++
- Title
- C++ string format ctime
- Category
- C++
- Title
- Html tab
- Category
- C++
- Title
- c++ iterate over vector
- Category
- C++
- Title
- E/flutter (20384): [ERROR:flutter/third_party/txt/src/minikin/FontFamily.cpp(184)] Could not get cmap table size! E/flutter (20384): F/flutter (20384): [FATAL:flutter/third_party/txt/src/minikin/FontCollection.cpp(95)] nTypefaces == 0
- Category
- C++
- Title
- c++ loop through int array
- Category
- C++
- Title
- subtracting two large numbers
- Category
- C++
- Title
- how to create a vector in c++
- Category
- C++
- Title
- initialization list c++
- Category
- C++
- Title
- char to string c++
- Category
- C++
- Title
- iterate const vector
- Category
- C++
- Title
- c++ char print fixed
- Category
- C++
- Title
- How to traverse in a tree iterative C++
- Category
- C++
- Title
- sfml basic program
- Category
- C++
- Title
- c++ find prime numbers
- Category
- C++
- Title
- basic cpp programs
- Category
- C++
- Title
- c++ vector size
- Category
- C++
- Title
- how to calculate trigonometric values in c++
- Category
- C++
- Title
- How to read a file in in C++
- Category
- C++
- Title
- invalid types int int for array subscript c++
- Category
- C++
- Title
- c++ string manipulation
- Category
- C++
- Title
- how to allocate on heap in c++
- Category
- C++
- Title
- c++ function to find minimum element in array
- Category
- C++
- Title
- c++ class method example
- Category
- C++
- Title
- factorial in c++
- Category
- C++
- Title
- how to declare function with multiple parameter c++
- Category
- C++
- Title
- c++ do while loop
- Category
- C++
- Title
- basic data types in c++ hackerrank solution
- Category
- C++
- Title
- set of vectors c++
- Category
- C++
- Title
- how to compare two strings lexicographically in c++
- Category
- C++
- Title
- matrix class in c++
- Category
- C++
- Title
- convert to lowercase c++
- Category
- C++
- Title
- C++ w3schools
- Category
- C++
- Title
- syntax c++
- Category
- C++
- Title
- how to write an or in c++
- Category
- C++