Computer Science, asked by ITKingShreyansh, 1 year ago

Write a program in bluej to check whether the number is Armstrong number or not?

Answers

Answered by shaivalini226p8uvju
3
class Armstrong
{
public static void main( int n )
{
int rem , sum = 0 n = num;
while(num >0)
{
rem = num % 10;
sum = sum + (rem * rem *rem);
num = num / 10
}
if ( sum == n)
S.O.P.("ARMSTRONG");
else
S.O.P.("NOT ARMSTRONG ");
}
}
Answered by lenovoideapadanishka
2

import java.util.*;

class armstrong  

{

public static void main(String args[])

{

Scanner sc=new Scanner(System.in);

int s=0,d,di;

System.out.println("enter a no.");

int n=sc.nextInt();

int x=n;

while(x!=0)

{

d=x%10;

di=d*d*d;

s=s+di;

x=x/10;

}

if(s==n)

System.out.println("armstrong");

else

System.out.println("not armstrong");

}

}

Hope it helps!!!^_^

please mark me as the brainliest!!!!!

Similar questions