fork download
  1.  
  2. /* Write a program to swap a nibble */
  3. //0101
  4. #include <stdio.h>
  5.  
  6. int main(void) {
  7. // your code goes here
  8. int num=23;
  9. int res= ((num&0x0F<<4) | (num&0xF0>>4));
  10. printf("%x", res);
  11. return 0;
  12. }
  13.  
  14. /*
  15. 0101 & 1111 = 0101 <<4 = 0101 0000
  16. 0101 & 1111 = 0101 >>4 = 0000 0000
  17. -----------------------------------
  18.   0101 0000
  19.   ----------
  20.   ---------
  21. */
Success #stdin #stdout 0s 5316KB
stdin
Standard input is empty
stdout
17