Advertisement
0xCor3

c

Oct 28th, 2019
282
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.71 KB | None | 0 0
  1. #include <string>
  2. #include <iostream>
  3.  
  4. using namespace std;
  5.  
  6. main()
  7. {
  8.   string array;
  9.   cout << "Enter binary number: "; cin >> array;
  10.   // Suppose the user inputs 10100
  11.   for(int i = 0; i <= array.size(); i++){
  12.     switch(array[i]){
  13.         case '0':
  14.             cout << "Nol ";
  15.             break;
  16.         case '1':
  17.             cout << "Satu ";
  18.             break;
  19.         case '2':
  20.             cout << "Dua ";
  21.             break;
  22.         case '3':
  23.             cout << "Tiga ";
  24.             break;
  25.         case '4':
  26.             cout << "Empat ";
  27.             break;
  28.         case '5':
  29.             cout << "Lima ";
  30.             break;
  31.         case '6':
  32.             cout << "Enam ";
  33.             break;
  34.         case '7':
  35.             cout << "Tujuh ";
  36.             break;
  37.         case '8':
  38.             cout << "Delapan ";
  39.             break;
  40.         case '9':
  41.             cout << "Sembilan ";
  42.             break;
  43.     }
  44.   }
  45.   return 0;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement