Write a C program to print Armstrong numbers
from 100 to 999.
Answers
Answered by
0
Answer:
#include <stdio.h>
int main(void)
{
int i = 100, rem, sum, temp, tnum;
printf("The 3-digit Armstrong numbers are : ");
for ( ; i <= 999; i++)
{
tnum = i;
sum = 0;
while (tnum > 0)
{
rem = tnum % 10;
temp = rem * rem * rem;
sum = temp + sum;
tnum = tnum / 10;
}
if (i == sum)
printf("%d\n", sum);
}
getch
Similar questions