Write a program to print out all the Armstrong number between 100 and 500.
Program in C Language
#include<stdio.h>
#include<conio.h>
int checkams(int num);
void main()
{
int i;
for(i=100;i<=500;i++)
{
if(checkams(i))
{
printf("%d\n",i);
}
}
getch();
}
int checkams(int num)
{
int digit,sum=0,temp;
// printf("enter an number\n");
// scanf("%d",&num);
temp=num;
while(num!=0)
{
digit=num%10;
num=num/10;
sum=sum+digit*digit*digit;
}
if(sum==temp)
{
return 1;
}
else
{
return 0;
}
}
No comments:
Post a Comment