⇧
Contact Us
||
Privacy Policy
||
About Us
Home
Java
Progarm
PHP
Menu ▼
Program
Vowel or Constant
Area of Circle
Find the Triangle
Compound Interest
Prime Number
Reverse Number
Factorial Number
Sum of Element
User Input
Calculate Average
Even or Odd
N Prime Number
1 to n Prime Number
Reverse String
Reverse String by User
Check Leap Year
HexaDecimal String
Binary to Decimal
Get IP
Check ArmStrong
ArmStrong Or Not
next →
← prev
21) Write a Program to check whether the input number is Armstrong or not .
Program
import java.util.Scanner; public class ArmEx { public static void main(String[] args) { int num, number, temp, total = 0; System.out.println("Enter 3 Digit Number"); Scanner scanner = new Scanner(System.in); num = scanner.nextInt(); scanner.close(); number = num; for( ;number!=0;number /= 10) { temp = number % 10; total = total + temp*temp*temp; } if(total == num) System.out.println(num + " is an Armstrong number"); else System.out.println(num + " is not an Armstrong number"); } }
Next Topic
← prev
next →