Advertisement
Mahfuz123

Binary

Aug 21st, 2019
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main()
  4. {
  5. int number,cnt,i;
  6. int bin[32];
  7.  
  8. printf("Enter decimal number: ");
  9. scanf("%d",&number);
  10.  
  11. cnt=0;
  12. while(number>0)
  13. {
  14. bin[cnt]=number%2;
  15. number=number/2;
  16. cnt++;
  17. }
  18. printf("Binary value is: ");
  19. for(i=(cnt-1); i>=0; i--)
  20. {
  21. printf("%d",bin[i]);
  22. }
  23.  
  24. return 0;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement