Reversing the Digits of an Integer

 

Reversing the digits of an integer involves rearranging the digits of the number such that the first digit becomes the last digit, the second digit becomes the second last digit, and so on.

 

Explanation

 

Objective :

The objective is to reverse the digits of a given integer.

Steps
  1. Input: Get the integer from the user.
  2. Initialize: Set up variables for the reversed number and the remainder.
  3. Iterate: Extract the last digit of the number and add it to the reversed number in the correct position.
  4. Output: Print the reversed number.

 

Algorithm in Pseudo-Code

 

 

C Implementation

 

 

Output 

 

 

Summary

 

This program reads an integer from the user, reverses its digits, and then prints the reversed number. It uses basic arithmetic operations to extract and append digits, demonstrating simple control structures and mathematical operations in C.