

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Write a C# program to check if the entered number is Armstrong number?
A number is an Armstrong number if the sum of the cube of each digit of the number is equal to the number itself.
Here, we will find out the remainder and will sum it to the cube of remainder.
rem = i % 10; sum = sum + rem*rem*rem;
Then if the above sum that comes out after loop iteration is equal to the sum, then it will be an Armstrong number.
if (sum == num) { Console.Write("Armstrong Number!"); }
The following is an example −
Example
int num, rem, sum = 0; // checking for armstrong number num = 153; for (int i = num; i > 0; i = i / 10) { rem = i % 10; sum = sum + rem*rem*rem; } if (sum == num) { Console.Write("Armstrong Number!"); } else Console.Write("Not an Armstrong Number!"); Console.ReadLine();
- Related Questions & Answers
- C# Program to Check Whether the Entered Number is an Armstrong Number or Not
- C++ Program to Check Armstrong Number
- C Program to Check Armstrong Number?
- Python Program to Check Armstrong Number
- Java Program to Check Armstrong Number
- Java program to check whether the given number is an Armstrong number
- Write a C# program to check if a number is Palindrome or not
- Write a C# program to check if a number is divisible by 2
- Write a C# program to check if a number is prime or not
- Python Program to Check if a Number is a Perfect Number
- Python Program to Check if a Number is a Strong Number
- Golang Program to Check if a Number is a Perfect Number
- Python program to check if the given number is a Disarium Number
- Check the number is Armstrong or not using C
- Python program to check if the given number is Happy Number
Advertisements