Advertisement
Patresss

Untitled

Aug 31st, 2014
499
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.51 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<limits.h>
  3. void dectobin(unsigned short a);
  4. int main(void)
  5. {
  6.     unsigned short a;
  7.     printf("od 0 do %d: ",USHRT_MAX);
  8.      scanf("%hu",&a);
  9.       printf("%hu to diesietna(10)\n",a);
  10.       dectobin(a);
  11.       printf("to wynik dwojkowo\n");
  12.       return 0; }
  13.  
  14.        void dectobin(unsigned short a)
  15.         {
  16.             int licznik;
  17.              licznik=(CHAR_BIT)*sizeof(a);
  18.              while(--licznik>=0)
  19.                 putchar(((a>>licznik)&1)? '1' : '0');
  20.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement