Advertisement
KateWilson

Untitled

Apr 16th, 2022
966
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.35 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     char s, str[80];
  8.     int t = 0, t2 = 0;
  9.     cin >> s;
  10.  
  11.     t = (int)(s);
  12.     char str = dec2bin(t);
  13.     /////
  14. }
  15.  
  16. int dec2bin(int num)
  17. {
  18.     int bin = 0, k = 1;
  19.  
  20.     while (num)
  21.     {
  22.         bin += (num % 2) * k;
  23.         k *= 10;
  24.         num /= 2;
  25.     }
  26.  
  27.     return bin;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement