Program:
package JavaCoders;
class armstrong
{
public static void main(String[] args)
public static void main(String[] args)
{
int c=0,a,temp;
int n=153; //It is the number to check armstrong
temp=n;
while(n>0)
{
a=n%10;
n=n/10;
c=c+(a*a*a);
}
if(temp==c)
int n=153; //It is the number to check armstrong
temp=n;
while(n>0)
{
a=n%10;
n=n/10;
c=c+(a*a*a);
}
if(temp==c)
{
System.out.println("armstrong number");
System.out.println("armstrong number");
}
else
{
{
System.out.println("Not armstrong number");
}
}
}
}
}
FIG: ARMSTRONG PROGRAM OUTPUT |
No comments:
Post a Comment