fork download
  1. /******************************************************************************
  2.  
  3. Welcome to GDB Online.
  4. GDB online is an online compiler and debugger tool for C/C++.
  5. Code, Compile, Run and Debug online from anywhere in world.
  6.  
  7. *******************************************************************************/
  8. #include <iostream>
  9. #include <bits/stdc++.h>
  10. using namespace std;
  11.  
  12. int main() {
  13. char hex[100], reversed[100];
  14. int length, i;
  15.  
  16. printf("Enter a hexadecimal number: ");
  17. scanf("%s", hex);
  18.  
  19. length = strlen(hex);
  20.  
  21. // Reverse the hex string
  22. for (i = 0; i < length; i++) {
  23. reversed[i] = hex[length - i - 1];
  24. }
  25. reversed[length] = '\0'; // Null-terminate the reversed string
  26.  
  27. printf("Reversed hexadecimal: %s\n", reversed);
  28.  
  29. return 0;
  30. }
Success #stdin #stdout 0s 5316KB
stdin
0xe45667a
stdout
Enter a hexadecimal number: Reversed hexadecimal: a76654ex0