## Find The Number Is Armstrong Or Not

###
**Introduction:**

For example, 153 is an Armstrong number because a cube of 1 is 1(1x1x1=1) + a cube of 5 is 125(5*5*5=125) + a cube of 3 is 27(3*3*3=27). Now add all the cubes 1+125+27=153 which equal to number itself.

###
**Algorithm of Armstrong Number:**

###
**Program to Find THE NUMBER IS ARMSTRONG OR NOT:**

#include<conio.h>

main()

{

int rem,sum=0,temp=0,n;

printf("\n Enter The Number");

scanf("%d",&n);

temp=n;

while(n!=0)

{

rem=n%10;

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

n=n/10;

}

if(sum==temp)

{

printf("\n The Number is Amstrong Number");

}

else

{

printf("\n The Number is not Amstrong Number");

}

getch();

}

**Output of Armstrong Number:**

**Here is the output generated by the program-**

**1st case:**

**2nd case:**

**3rd case:**

**Discussion:**

**Three-digit numbers are 000, 001, 002, ..., 009, 010, 011, ..., 019, 020, 021, 022, ..., 099, 100, 101, 102, ..., 109, 110, ... 990, 991, ..., 999. As you can see the right-most digits changes faster than the middle one, which in turn is faster than the left-most one.**

As the left-most and the middle digits are fixed to 0 and 0, the right-most digit changes from 0 to 9. Then, the middle one is increased from 0 to 1.

In other words, whenever the right-most digit completes a 0 to 9 cycle, the middle digit is increased by one and the right-most digit restart another 0 to 9 cycle. By the same token, whenever the middle digit completes a 0 to 9 cycle, the left-most digit is increased by 1 and the middle digit restarts another 0 to 9 cycle.

## No comments:

## Post a Comment