Write a Java program to find whether the given number is Armstrong or not code example
Example: armstrong number in java
import java.util.Scanner;
public class Armstrong
{
public static void main(String args[])
{
int num,temp,c=0;
Scanner in=new Scanner(System.in);
num=in.nextInt();
temp=num;
while(num!=0)
{
int d=num%10; //extracting last digit
c+=d*d*d;
num/=10; // removing last digit
}
if(temp==c)
{
System.out.println("Number is Armstrong");
}
else
System.out.println("Number is not Armstrong");
}
}