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}
1//Bismillahir Rahmanir Rahim
2#include <stdio.h>
3#include <math.h>
4
5int digit(int n, int count){
6 while( n != 0){
7 n/=10;
8 count++;
9 }
10 return count;
11}
12
13int main(){
14 int n, rem, num, sum = 0, count = 0, digits;
15 while(1){
16 printf("Enter a number (type 0 to exit) : ");
17 scanf("%d", &n);
18
19 if(n==0){
20 break;
21 }
22 digits = digit(n,count);
23
24 num=n;
25 while(num != 0){
26 rem = num % 10;
27 sum += pow(rem,digits);
28 num /= 10;
29
30 }
31
32 if(sum == n){
33 printf("%d is an armstrong number!\n", n);
34 sum = 0;
35 }else{
36 printf("%d is not an armstrong number!\n", n);
37 sum = 0;
38 }
39
40 }
41
42 return 0;
43}