1temp=n;
2while(n>0)
3{
4r=n%10;
5sum=sum+(r*r*r);
6n=n/10;
7}
8if(temp==sum)
9printf("armstrong number ");
10else
11printf("not armstrong number");
12return 0;
1#include<stdio.h>
2int main()
3{
4 int num ,n,n1,c=0,mul=1,sum=0,r,f,i;
5 printf("enter any num: \n");
6 scanf("%d",&num);
7 n=num;
8 n1=num;
9 while(n!=0)
10 {
11 r=n%10;
12 c++;
13 n=n/10;
14 }
15 while (num!=0)
16 {
17 f=num%10;
18 mul=1;
19 for(i=1;i<=c;i++)
20 {
21 mul=mul*f;
22 }
23
24 sum=sum+mul;
25 num=num/10;
26 }
27 if(n1==sum)
28 printf("Armstrong Number");
29 else
30 printf("Not an Armstrong Number");
31 return 0;
32}
1// Armstrong Numbers
21, 2, 3, 4, 5, 6, 7, 8, 9, 153, 370, 371, 407, 1634, 8208, 9474, 54748...
1 <form method="post">
2 Enter the Number:
3 <input type="number" name="number">
4 <input type="submit" value="Submit">
5 </form>
6 <?php
7 if ($_POST) {
8 //get the number entered
9 $number = $_POST['number'];
10 //store entered number in a variable
11 $a = $number;
12 $sum = 0;
13 //run loop till the quotient is 0
14 while ($a != 0) {
15 $rem = $a % 10; //find reminder
16 $sum = $sum + ($rem * $rem * $rem) || $sum = $rem; //cube the reminder and add it to the sum variable till the loop ends
17 $a = $a / 10; //find quotient. if 0 then loop again
18 }
19 //if the entered number and $sum value matches then it is an armstrong number
20 if ($number == $sum) {
21 echo "Yes $number an Armstrong Number";
22 } else {
23 echo "$number is not an Armstrong Number";
24 }
25 }
26//here is another example using while loop
27
28$num=300;
29$total=0;
30$x=$num;
31while($x!=0){
32$rem=$x%10;
33$total=$total+($rem*$rem*$rem);
34$x=$x/10;
35}
36if($num==$total){
37 echo "Yes it is an Armstrong number";}
38else
39{echo "No it is not an armstrong number";}