fork download
  1.  
  2. /* Write a program to swap a nibble */
  3.  
  4. //a = 1000 1001
  5. //output b = 1001 1000
  6.  
  7. #include <stdio.h>
  8.  
  9. int swapNibble(int n)
  10. {
  11. n = (n&0x0f) << 4 | n >> 4;
  12. return (n);
  13. }
  14.  
  15. int main(void) {
  16. // your code goes here
  17. printf("swapped nibble %x",swapNibble(0x54));
  18. return 0;
  19. }
  20.  
Success #stdin #stdout 0s 5312KB
stdin
Standard input is empty
stdout
swapped nibble 45