Ans:-
#include<stdio.h>
main()
{
int num,n,rem;
int cube=0,sum;
printf("\n armstrong number between 100 and 999 are:");
for(num=100;num<=999;num++)
{
sum=0;
n=num;
do
{
rem=n%10;
cube=rem*rem*rem;
sum=sum+cube;
n=n/10;
}while(n>0);
if(num==sum)
{
printf("\n %d is armstrong number",num);
}
getch();
}
}
#include<stdio.h>
main()
{
int num,n,rem;
int cube=0,sum;
printf("\n armstrong number between 100 and 999 are:");
for(num=100;num<=999;num++)
{
sum=0;
n=num;
do
{
rem=n%10;
cube=rem*rem*rem;
sum=sum+cube;
n=n/10;
}while(n>0);
if(num==sum)
{
printf("\n %d is armstrong number",num);
}
getch();
}
}
Comments
Post a Comment