Advertisement
kamandos

HomeWork

Jul 16th, 2022
862
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.29 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main() {
  4.  
  5.   int n, reverse = 0, remainder;
  6.  
  7.   printf("Enter an integer: ");
  8.   scanf("%d", &n);
  9.  
  10.   while (n != 0) {
  11.     remainder = n % 10;
  12.     reverse = reverse * 10 + remainder;
  13.     n /= 10;
  14.   }
  15.  
  16.   printf("Reversed number = %d", reverse);
  17.  
  18.   return 0;
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement