Java program to count armstrong number between 100 to 1000 | Sololearn: Learn to code for FREE!
0

Java program to count armstrong number between 100 to 1000

Pls help me out...

27th Feb 2019, 10:38 AM
saravana kumar
saravana kumar - avatar
2 odpowiedzi
27th Feb 2019, 10:41 AM
Anna
Anna - avatar
0
public class Amstrong { public static void main(String[] args) { int n; int sum = 0; int rem; int count = 0; System.out.print("Armstrong number between 100 to 1000 :"); for(int i=100;i<=1000;i++){ n = i; while(n>0){ rem = n % 10; rem = (rem * rem * rem); sum = sum + rem; n = n /10; } if(sum == i){ System.out.print("\n"+i); count++; } sum=0; } } }
27th Feb 2019, 10:52 AM
saravana kumar
saravana kumar - avatar