**Article by:** Manish Methani

**Last Updated:** September 26, 2021 at 2:04pm IST

An Armstrong number is a number that equals the sum of the cube of each digit in a number.

**For example**, suppose a given number is 153.

To check whether a given number is Armstrong or not, we have to take the cube of each digit in a number and take a sum of those.

153 = (1*1*1) + (5*5*5) + (3*3*3)

After the addition of the cube of each digit, we get the original number which is 153. Hence, the given number is Armstrong.

#include <stdio.h> int main() { int n = 153, sum = 0, remainder = 0,tempNumber; tempNumber = n; while(tempNumber!=0) { remainder = tempNumber % 10; sum = sum + (remainder*remainder*remainder); tempNumber /= 10; } if(sum==n) { printf("%d is an Armstrong number.",n); } else { printf("%d is not an Armstrong number.",n); } return 0; }

153 is an Armstrong number

- First, we take the original number into a temporary variable which is tempNumber.
- Then, we get the last digit of a temporary number using the modulo method inside a loop.
- After getting the last digit of a number, we added it with the cube of that last digit number.
- Then assigned the remaining digits except for the last digit of a number using the Quotient method.
- This process will be in the loop till we find that givenNumber do not reach 0.

If at the end we find that this new number after addition is found as. same or not. If yes, then the given number is an Armstrong number else it is not an Armstrong number.

#include <stdio.h> int isArmstrong(int n) { int tempNumber=n; int remainder,sum; sum=0; while(tempNumber!=0) { remainder=tempNumber%10; sum = sum + (remainder*remainder*remainder); tempNumber/=10; } if(sum==n) return 1 else return 0; } int main() { int n = 153; if(isArmstrong(n)) printf("%d is an Armstrong number.",n); else printf("%d is not an Armstrong number.",n); return 0; }

153 is an Armstrong number

10 OS Interview Questions you must know in 2024

10 Angular Interview Questions you must know in 2024

10 Javascript Interview Questions you must know in 2024

Top 10 DSA Interview Questions You should not miss

Top 10 Web Development Interview Questions

Introduction to Next.js

Altina Schinasi: Celebrating the Visionary Designer of Cat-Eye Frames | Google Doodle Tribute

Best Niche for Blogging in USA: A Comprehensive Guide

18 Must-Do Activities for Computer Science Students in College

13 Essential Things Solopreneurs need to know in 2024

25 Practical ways to earn money online

The Power of Gratitude - A Journey to Personal Growth

Top 5 Technology Trends That Are Shaping Our Future

5 Books You Need to Read Right Now

How to answer tell me about yourself?

What Angular feature transforms data before displaying it in the view?

Which widget is used in Flutter to create a button?

6 Mobile App Ideas That You Can Start in 2024

Flutter Widget Showdown: Exploring the Developers Favorite for Layouts!

Mobile App

For Engineers.

Mock Tests.

Test your C Programming skills with this comprehensive mock test on C Programming.

Take TestSolve most asked Interview Questions on Flutter and Test your foundational skills in flutter.

Take TestSolve most asked GATE Questions in Operating Systems and test your Gate Score.

Take TestThis is a mock test designed to help you assess your knowledge and skills in HTML and CSS.

Take TestSolve most asked GATE Questions in Data Structures and Algorithms and test your Gate Score.

Take Test