---
title: "Flowchart to reverse integer"
subject: "Computer Programming"
chapter: 2
key: "semester_1/computer_programming:flowchart-reverse-number"
source: https://www.bctengineer.com/q/semester_1/computer_programming/flowchart-reverse-number
site: BCT Engineering
---

# Flowchart to reverse integer

Computer Programming · Chapter 2: Problem solving using Computer

- Asked in: 2069 Chaitra, 3 marks
- Video: [Algorithm for find reversed number of a given number | Algorithm & Flowchart PART 11](https://www.youtube.com/watch?v=S8Z5N8efbHY) — PMGURU
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_1/computer_programming/flowchart-reverse-number
- Whole chapter: https://www.bctengineer.com/md/semester_1/computer_programming/chapter-2

## Question

Draw a flowchart to find the reverse of an integer number. For example, 12345 is an integer number and its reverse is 54321.

## Short answer

Repeatedly extract the last digit with N mod 10, build the reversed number as REV = REV*10 + digit, and set N = N/10 until N becomes 0. For 12345 the reversed output is 54321.

## Answer

The digits are taken one by one from the right using `N mod 10` and added to the reversed number after multiplying it by 10.

```text
        ( Start )
            |
       / Read N /
            |
        [ REV = 0 ]
            |
     +----->|
     |      v
     |  < N > 0 ? >--No--> / Print REV / --> ( Stop )
     |      | Yes
     |  [ R = N mod 10 ]
     |  [ REV = REV*10 + R ]
     |  [ N = N div 10 ]
     +------+
```

Dry run for N = 12345:

| N | R | REV |
|---|---|---|
| 12345 | 5 | 5 |
| 1234 | 4 | 54 |
| 123 | 3 | 543 |
| 12 | 2 | 5432 |
| 1 | 1 | 54321 |
| 0 | stop | 54321 |

Output: 54321.

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. The last digit of N is obtained by
   A. N div 10
   B. N * 10
   C. N mod 10
   D. N - 10
   Answer: C. Remainder on division by 10. (Key point: Digit extraction)

2. REV is updated as
   A. REV = REV + R
   B. REV = R
   C. REV = REV*R
   D. REV = REV*10 + R
   Answer: D. Shift left and add digit. (Key point: Build reverse)

3. The digit is removed from N using
   A. N = N div 10
   B. N = N mod 10
   C. N = N - 1
   D. N = N * 10
   Answer: A. Integer division drops the last digit. (Key point: Remove digit)

## Related in Computer Programming

- [Algorithm and flowchart help; Armstrong flowchart](https://www.bctengineer.com/question.md?key=semester_1%2Fcomputer_programming%3Aalgorithm-flowchart-armstrong) — Computer Programming, chapter 2
- [Reverse a string using functions](https://www.bctengineer.com/question.md?key=semester_1%2Fcomputer_programming%3Astring-reverse-with-count-function) — Computer Programming, chapter 7, asked 2×
- [Check triangular number](https://www.bctengineer.com/question.md?key=semester_1%2Fcomputer_programming%3Atriangular-number) — Computer Programming, chapter 5
- [Algorithm for numbers divisible by 9 not 6](https://www.bctengineer.com/question.md?key=semester_1%2Fcomputer_programming%3Aalgo-flowchart-divisible-9-not-6) — Computer Programming, chapter 2
- [Palindrome check in FORTRAN](https://www.bctengineer.com/question.md?key=semester_1%2Fcomputer_programming%3Afortran-palindrome) — Computer Programming, chapter 11
- [Sum of digits until single digit](https://www.bctengineer.com/question.md?key=semester_1%2Fcomputer_programming%3Adigit-sum-single-digit) — Computer Programming, chapter 5, asked 2×

## Related in other subjects

- [Prime number checking processor](https://www.bctengineer.com/question.md?key=semester_6%2Fembedded_system%3Aspp-prime-check) — Embedded System, chapter 2
