Environmental Sciences, asked by riya98765, 8 months ago

Write a java program to print Armstrong no. between 100-999. give right answer​

Answers

Answered by shivaniyadav33
2

Answer:

public static void main(String[] arg) { int i=100,arm; System. out. println("Armstrong numbers between 100 to 999");

while(i<1000) { arm=armstrongOrNot(i); if(arm==i)

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

int x,a=0; while(num!=0) { x=num%10;

a=a+(x*x*x); num/=10 ; } return a;

Answered by Intelligentcat
168

Answer:

\Large{\underline{\underline{\bf{QuEsTiOn:-}}}}

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

\mathfrak{\huge{\pink{\underline{\underline{Answer :}}}}}

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+" ");

}

\huge\bold\star\red{Output}\star

Armstrong numbers from 100 to 999 are:

153

370

371

407.

Attachments:
Similar questions