Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- void decToBinary(int input)
- {
- int binaryNum[32];
- int i = 0;
- while (input > 0) {
- binaryNum[i] = input % 8;
- input = input / 8;
- i++;
- };
- cout<<"Hasilnya ";
- for (int j = i - 1; j >= 0; j--){
- cout << binaryNum[j];
- };
- }
- int main()
- {
- int input;
- cout<<"Masukan bilangan decimal : ";
- cin>>input;
- if(input < 0){
- cout<<"Masukan Bilangan Decimal Yang Lebih Dari 0";
- }else{
- decToBinary(input);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment