Important Notice:

Reversing digits algorithm flowchart

Reversing digits algorithm flowchart

3 views 1 min read

Reverse Digits of an Integer किसी Integer के Digits को Reverse करना Question

Write an algorithm and flowchart to reverse the digits of an integer.

Example

Input: 12345
Reversed Number: 54321

Logic -

DIGIT = N % 10
REV = REV × 10 + DIGIT
N = N // 10

Algorithm

  1. Start.
  2. Input an integer N.
  3. Set REV = 0.
  4. Find the last digit: DIGIT = N % 10.
  5. Set REV = REV × 10 + DIGIT.
  6. Remove the last digit: N = N // 10.
  7. If N > 0, repeat Steps 4 to 6.
  8. Display REV.
  9. Stop.

 

Related Notes