Crackbone

dv5z3

Apr 18th, 2021
615
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*3. Napisati funkciju koja ispisuje broj n u binarnom zapisu. Koristiti bitovne operatore.
  2. Primjer: Za broj n = 200, ispisuje se 11001000.*/
  3.  
  4. #define _CRT_SECURE_NO_WARNINGS
  5.  
  6. #include<stdio.h>
  7.  
  8. int dTb(int);
  9.  
  10. int main()
  11. {
  12.     int number;
  13.     printf("Unesi broj:\n");
  14.     scanf(" %d", &number);
  15.     printf("\n");
  16.     printf("Binarni broj je: %d", dTb(number));
  17.     getchar();
  18.     getchar();
  19.     return 1;
  20. }
  21.  
  22. int dTb(int number)
  23. {
  24.     int bin_numb=0, remain, temp=1;
  25.     while (number > 0)
  26.     {
  27.         remain = number % 2;
  28.         number = number / 2;
  29.         bin_numb = bin_numb + remain * temp;
  30.         temp = temp * 10;
  31.  
  32.     }
  33.  
  34.  
  35.     return bin_numb;
  36. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×