1#include <stdio.h>
2int main() {
3 int num, originalNum, remainder, result = 0;
4 printf("Enter a three-digit integer: ");
5 scanf("%d", &num);
6 originalNum = num;
7
8 while (originalNum != 0) {
9 // remainder contains the last digit
10 remainder = originalNum % 10;
11
12 result += remainder * remainder * remainder;
13
14 // removing last digit from the orignal number
15 originalNum /= 10;
16 }
17
18 if (result == num)
19 printf("%d is an Armstrong number.", num);
20 else
21 printf("%d is not an Armstrong number.", num);
22
23 return 0;
24}
25
1#include <stdio.h>
2#include <math.h>
3void main ()
4{
5 int n,t,r,c,s=0;
6 printf("Enter the number: ");
7 scanf("%d",&n);
8 t=n;
9
10 while(t!=0)
11 {
12 r=t%10;
13 c=pow(r,3);
14 s=s+c;
15 t=t/10;
16 }
17
18 if(s==n)
19 printf("Armstrong");
20 else
21 printf("Not Armstrong");
22}
23
1#include <stdio.h>
2#include <stdlib.h>
3#include <math.h>
4
5int cube(int a)
6{
7 int c;
8 c = a*a*a;
9 return c;
10}
11
12int armnum(int *a)
13{
14 int x = *a, n = 0, rem, r = 0;
15 while (x != 0) {
16 x /= 10;
17 n++;
18 }
19 x = *a;
20 while (x != 0) {
21 rem = x % 10;
22 r += cube(rem);
23 x /= 10;
24 }
25 if(r == *a){
26 return 1;
27 }
28}
29
30int main()
31{
32 int a, y;
33 scanf("%d", &a);
34 y = armnum(&a);
35 if(y == 1){
36 printf("It is an Armstrong number.");
37 }
38 else{
39 printf("It is not an Armstrong number.");
40 }
41}