Computer Science, asked by ranisanju2020, 22 days ago

Write an algorithm to check whether the given number is an Armstrong number or not ?​

Answers

Answered by TheUntrustworthy
1

Algorithm:

An Armstrong number is a number whose sum of cubes of digits is equal to the number itself.

For example:

153 = 1³+5³+3³

1+125+27

=153

Program in Java:

import java. util.*;

class Armstrong

{

public static void main (string args [])

{

Scanner sc = new Scanner

int n, r, p, s=0, m;

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

n=sc.nextInt();

while

{

r=n%10

p=r*r*r;

s=s+p;

n=n/10;

}

if (m==s)

System.out.println (m+"is Armstrong");

else

System.out.println (m+"is not Armstrong");

}

}

Learn More:

Write a menu driven program to accept a number and cheack weather it is a prime number or a perfect number as per the us...

https://brainly.in/question/18042462

Creat a program to chack where a number is buzz number or not

https://brainly.in/question/12156124

Write a program to find the name of the month using switch statement

https://brainly.in/question/27637303

Similar questions