Computer Science, asked by Jugal9108, 7 months ago

Send your computer programe (code of coding)in any language like html java python etc...​

Answers

Answered by Anonymous
1

Answer:

it is java.....

Write a program to check whether give number is Armstrong number or not.

import java.util.Scanner;

class Armstrong_Number  

{

public static void main(String args[])  

{

Scanner sc=new Scanner(System.in);

System.out.println("Enter any number"); // to input number

int n=sc.nextInt(); int t=n,sum=0; // to store number and copy of number and sum

while (t>0) // till the number is greater than 0

{

int a=t%10; // to extract last digit

sum=sum+(a*a*a); // to add all digit cubes

t=t/10; // to reduce number

}

if(sum==n)

System.out.println(n+" is a Armstrong Number"); // if condition is true

else

System.out.println(n+" is not a Armstrong Number"); // if condition is false

}//main method ends and

} //  class ends

OUTPUT:

enter a no.

371

armstrong number

enter a no.

546

Not an armstrong number

Similar questions