Advertisement
Istanvir389

decimal to Binary conversion

Sep 25th, 2017
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.28 KB | None | 0 0
  1. #include<stdio.h>
  2. int main()
  3. {
  4.     int num,r,j,i=0;
  5.     int bin[1000];
  6.     scanf("%d",&num);
  7.     while(num!=0)
  8.     {
  9.         r=num%2;
  10.         num=num/2;
  11.         bin[i]=r;
  12.         i++;
  13.     }
  14.     for(j=i-1;j>=0;j--)
  15.     {
  16.         printf("%d",bin[j]);
  17.     }
  18.     return 0;
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement