Java Program to Check If a Number is Armstrong number or not
Armstrong number:-
Algorithm:-
Program:-
class Armstrong
{
public static void main(String[] args)
{
System.out.println("Enter the 3 digit value");
int n1=new java.util.Scanner(System.in).nextInt();
int num, rem, sum=0;
num=n1;
while(num>99)
{
while(num>0)
{
rem=num%10;
sum=sum+rem*rem*rem;
num=num/10;
}
}
if(sum==n1)
{
System.out.println(n1 + " is a Armstrorg number ");
}
else
{
System.out.println(n1 + " is a not Armstrong number");
}
}
}
For Proper Understanding Watch the Video :-
Thanks;)
All the Best :)
Keep Learning:)
Study:)
Self:)
No comments:
Post a Comment