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

**Ans.**

__Definition of__An Armstrong number of three digits is an integer such that the sum of the cubes of its digits is equal to the number itself.

**Armstrong number**:
In other word

**“A number is Armstrong if it is equal the sum of cube of its digits.”****Example**of Armstrong number is 371 because according to definition cube of its digits sum will be equal to number so

Armstrong number 371=(3)

^{3}+(7)^{3}+(1)^{3}
371=27+343+1

371=371

/*program to check whether a number is Armstrong or not*/

**#include**<stdio.h>

**#include**<conio.h>

int main()

{

int n,num,rem,sum=0;

printf("Enter any number : ");

scanf("%d",

**&**num);
for(n=num; n>=1; n=n/10)

{

rem=n%10;

sum=sum+(rem*rem*rem);

}

if(num==sum)

printf("Number is Armstrong number");

else

printf("Number is not Armstrong number");

getch();

getch();

**return 0**;

}

__Output__:-
Enter any number :

**254****Entered number is not Armstrong number**

Enter any number :

**371****Entered number is Armstrong number**

*Related Program:*

its not work for more than 3 digit number

ReplyDelete