1#include<iostream>
2#include<stack>
3using namespace std;
4void dec_to_bin(int number) {
5 stack<int> stk;
6 while(number > 0) {
7 int rem = number % 2; //take remainder
8 number = number / 2;
9 stk.push(rem);
10 }
11 while(!stk.empty()) {
12 int item;
13 item = stk.top();
14 stk.pop();
15 cout << item;
16 }
17}
18main() {
19 int num;
20 cout << "Enter a number: ";
21 cin >> num;
22 dec_to_bin(num);
23}