Ad

Instead of infinite while, with an if statement that breaks, just put the condition in the while loop.

Code
Diff
  • #include <stdlib.h>
    #include <math.h>
    
    int reverse_int(int int_reverse) {
      int o = 0;
      while (int_reverse != 0) {
        o *= 10;
        o += int_reverse % 10;
        int_reverse /= 10;
      }
      return o;
    }
    • #include <stdlib.h>
    • #include <math.h>
    • int reverse_int(int int_reverse) {
    • int o = 0;
    • while (1) {
    • o += ((int)int_reverse % 10);
    • if (int_reverse /= 10)
    • o *= 10;
    • else break;
    • while (int_reverse != 0) {
    • o *= 10;
    • o += int_reverse % 10;
    • int_reverse /= 10;
    • }
    • return o;
    • }