/*print all three digit Armstrong numbers*/
#include<stdio.h>
void main() {
int n, n1, n2, n3, n4, t;
printf("\nThe three digit Armstrong numbers are: ");
for (n = 100; n <= 999; n++) {
n1 = n % 10;
n2 = n / 10;
n3 = n2 % 10;
n4 = n2 / 10;
t = n1 * n1 * n1 + n4 * n4 * n4 + n3 * n3 * n3;
if (n == t)
printf("%9d", t);
}
}
WHAT'S NEW?
Loading...
0 comments:
Post a Comment