Skip to content
Exercise · Q16

Q.Draw a flowchart to check whether a given number is an Armstrong number. An Armstrong number of three digits is an integer such that the sum of the cubes of its digits is equal to the number itself. For example, 371 is an Armstrong number since 33 + 73 + 1**3 = 371.

Telangana TsbieTextbookSubjective· 3mImportance★★★★★est
94% · 34/36 Questions
🔒 Locked · start free trial →

You're viewing a preview — the full solution, concept, methods & PYQ mapping are locked.

Start your 14-day free trial to unlock the full solution →

Loop-extract the digits with MOD 10 and DIV 10, accumulate the cube of each digit, then compare the sum with the original number — equal means Armstrong.

The idea (Armstrong check). A 3-digit number is an Armstrong number when the sum of the cubes of its digits equals the number itself (371 → 27 + 343 + 1 = 371). The algorithmic core is digit extraction: temp MOD 10 yields the last digit and temp DIV 10 (integer division) removes it, repeated until temp is 0. We must keep the original number safe in NUM while a copy (temp) is destroyed, so the final comparison is still possible.

Flowchart — nodes and arrows

#ShapeTextArrows out
1Rounded rectangleStart→ 2
2ParallelogramInput NUM→ 3
3Rectangletemp = NUM ; sum = 0→ 4
4Diamondtemp > 0 ?Yes → 5 · No → 6
5Rectangledigit = temp MOD 10 ; sum = sum + digit × digit × digit ; temp = temp DIV 10→ back to 4
6Diamondsum == NUM ?Yes → 7 · No → 8
7ParallelogramPrint "NUM is an Armstrong number"→ 9
8ParallelogramPrint "NUM is not an Armstrong number"→ 9
9Rounded rectangleStop—

Python verification

NUM = int(input("Enter a 3-digit number: "))
temp = NUM
total = 0
while temp > 0:
    digit = temp % 10
    total = total + digit ** 3
    temp = temp // 10
if total == NUM:
    print(NUM, "is an Armstrong number")
else:
    print(NUM, "is not an Armstrong number")

Dry run for NUM = 371

| Pass | temp (start) | digit | total after adding digit³ | temp after DIV 10 | …

Unlock everything free for 14 days

  • Full step-by-step solutions
  • Concept-first explanations
  • Methods, shortcuts & mistakes
  • PYQ mapping + timed mock tests

Full access for 14 days. No credit card required.