Computer Science, asked by riya98765, 7 months ago

Write a program to input a no. and print if it's Armstrong or not. tell only the answer which is correct . ​

Answers

Answered by lalankumar99395
5

Answer:

Let's see the c program to check Armstrong Number in C.

#include<stdio.h>

int main()

{

int n,r,sum=0,temp;

printf("enter the number=");

scanf("%d",&n);

temp=n;

Answered by Intelligentcat
228

Answer:

Answer:

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

Write a program to input a no. and print if it's Armstrong or not.

\huge\underline{\overline{\mid{\bold{\pink{ANSWER-}}\mid}}}

import java.util.Scanner ;

public class Armstrong

{

public static void main (String args[ ] )

{

Scanner sc = new Scanner(System.in) ;

System.out.print("Enter a 3digit number to be checked:") ;

int num= sc.nextInt( ) ;

int check = 0, remainder;

do {

remainder = n % 10 ;

check = check + (int)Math.pow(remainder,3) ;

n = n / 10 ;

} while (n != 0) ;

if (check = = num )

System.out.println(num + "is an Armstrong Number") ;

else

System.out.println(num + "is not a Armstrong Number") ;

}

}

Example output:

Enter a 3 digit number to be checked : 345

345 is not a Armstrong number

Similar questions