Computer Science, asked by tanya2601, 1 year ago

Write a program to print all armstrong number from 1 to n...

Answers

Answered by siddhartharao77
7

import java.util.*;

class Sample

{

public static void main(String args[])

{

Scanner demo = new Scanner(System.in);

int a,b,c = 0, d;

System.out.println("Enter a number :");

a = demo.nextInt();

b = a;

while(a > 0)

{

d = a % 10;

c = c+(d*d*d);

a = a/10;

}

if(b == c)

{

System.out.println("Armstrong number");

}

else

{

System.out.println("Not armstrong number");

}

}

}


Output:

Enter a number : 153

Armstrong number.



Hope it helps!


Anonymous: gud u are intelligent man!!
siddhartharao77: Thanks!
Anonymous: ur wlcm are u a student bcs by seing ur answers
Anonymous: it is shocked so much matured answers
Anonymous: can do one favour pliss
Anonymous: do u know any moderator
Anonymous: so plis tell them to delete my account canu say them please
Anonymous: please
Similar questions