Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <string>
- #include <iostream>
- using namespace std;
- main()
- {
- string array;
- cout << "Enter binary number: "; cin >> array;
- // Suppose the user inputs 10100
- for(int i = 0; i <= array.size(); i++){
- switch(array[i]){
- case '0':
- cout << "Nol ";
- break;
- case '1':
- cout << "Satu ";
- break;
- case '2':
- cout << "Dua ";
- break;
- case '3':
- cout << "Tiga ";
- break;
- case '4':
- cout << "Empat ";
- break;
- case '5':
- cout << "Lima ";
- break;
- case '6':
- cout << "Enam ";
- break;
- case '7':
- cout << "Tujuh ";
- break;
- case '8':
- cout << "Delapan ";
- break;
- case '9':
- cout << "Sembilan ";
- break;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement