Write a java Program to print Armstrong number between 1 to 1000

Write a java Program to print Armstrong number between 1 to 1000

Write a java Program to print Armstrong number between 1 to 1000

Program

public class Main 
{
    public static void main(String[] args) 
    {
        int num,rem,limit=1000, sum = 0; 
        System.out.print("Armstrong numbers from 1 to N:"); 
        for (int i = 1; i <= limit; i++) 
        {
            num = i;
            while (num > 0) 
            {
                rem = num % 10;
                sum = sum + (rem*rem*rem);
                num = num / 10; 
            }
            if (sum == i) 
            {
                System.out.print(i + " "); 
            }
            sum = 0;
        }
    }
}


Output:

Armstrong numbers from 1 to N:
1
153
370
371
407



More Questions


32 . Write a Java Program to find Armstrong number
33 . Write a java Program to print Armstrong number between 1 to 1000
34 . Write a java Program to Print given number in words
35 . Write a java Program to check the given number is Palindrome or not
36 . Write a java Program to print palindrome number upto N numbers
37 . Write a java Program to print N prime numbers and find sum and average
38 . Write a Java Program to find largest number in an array
39 . Write a Program to find second largest number in an array
40 . Write a Program to Find largest and smallest number in an array in java
41 . Write a Java Program to find largest and second largest in an array
42 . Write a java program to find the index of the largest number in an array



For latest job updates join Telegram Channel: https://t.me/sateeshm

Apply For The Job

Apply For Job

Java Material

Python Material

PLSQL Material

.Net Material

Java Practice Programs

400 Java Programs