APC-PRAC-037.c ​
Metadata ​
- Author — Amit Dutta
- Last updated — 12 Dec 2025
- License — MIT License (See the LICENSE file for details)
Problem Statement ​
Problem Statement
Show all the armstrong number between a range.
Source Code ​
Printing the code
To print this file, open it on GitHub and click Raw before printing, or use the Download Raw button above and print directly from that page.
c
#include <stdio.h>
#include <math.h>
#define lowerBound 100
#define upperBound 999
int isArmstrongNumber(int);
int isArmstrongNumber(int n)
{
int temp = n, sum = 0, count = 0;
while (temp > 0)
{
count++;
temp /= 10;
}
temp = n;
while (temp > 0)
{
sum += (int)pow(temp % 10, count);
temp /= 10;
}
return sum == n;
}
int main()
{
int n, i, count = 0;
printf("Armstrong number between %d and %d are: ", lowerBound, upperBound);
for (i = lowerBound; i <= upperBound; i++)
if (isArmstrongNumber(i))
{
printf("%d ", i);
count++;
}
printf("\n\nCount: %d\n", count);
return 0;
}1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38