Computer Science, asked by BrainlyPromoter, 1 year ago

Write a java program to print Armstrong numbers between 100-999.

Answers

Answered by siddhartharao77
19

Sample Java program to Print armstrong number:

class Brainly

{

public static void main(String args[])

{

int k, j = 0, i;

System.out.println("Armstrong numbers from 100 to 999 are: ");

for(i = 100; i <= 1000; i++)

{

int a = i;

j = 0;

while(a > 0)

{

k = a%10;

j = j + (k * k * k);

a=a/10;

}

if(j==i)

{

System.out.println(i+" ");

}

Output:

Armstrong numbers from 100 to 999 are:

153

370

371

407.

<!Hope it helps..!>

Attachments:
Answered by sk181231
1

Answer:

Write a java program to print Armstrong numbers between 100-999.

Armstrong number in Java. Here we have written the code in four different ways standard, using for loop, recursion, while loop and also with different examples as like: between 100 and 999, between 1 to 1000 and between 1 to 500 with sample outputs and online execution tool embedded.

Here is the first sample program using the static method with sample output as well. Here we used the method ‘ Static ‘ and taken numbers between 100 to 999. Once you are done with the execution, it automatically displays the Armstrong numbers between 100 and 999. Check out the sample output.

Attachments:
Similar questions
Math, 1 year ago