Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int getBinarni(int);
- int main() {
- int broj;
- cout << "Unesite broj u decimalnom zapisu: ";
- cin >> broj;
- cout << "Binarni ekvivalent unesenog broja je " << getBinarni(broj) << ".";
- system("pause>0");
- return 0;
- }
- int getBinarni(int broj) {
- int bin = 0;
- while (broj)
- {
- bin = bin * 10 + broj % 2;
- broj /= 2;
- }
- return bin;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement