Advertisement
Babhero10

Reverse numbers

Mar 25th, 2019
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.30 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main(void)
  5. {
  6.     int num = 0, length = 1, Rnum = 0;
  7.     scanf("%i", &num);
  8.     if(num < 0)
  9.     {
  10.         num *= -1;
  11.     }
  12.    
  13.     printf("reverse: ");
  14.    
  15.     while(num >= 1)
  16.     {
  17.         printf("%i", num % 10);
  18.         Rnum += num * length;
  19.         length  *= 10;
  20.         num /= 10;
  21.     }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement