Write
a c program for Armstrong number
#include<stdio.h>
main()
{
int num,r,sum,temp,min,max;
printf("Enter the minimum range: ");
scanf("%d",&min);
printf("\nEnter the maximum range: ");
scanf("%d",&max);
printf("\nArmstrong numbers in given range are: ");
printf("\n");
for(num=min;num<=max;num++)
{
temp=num;
sum = 0;
while(temp!=0)
{
r=temp%10;
temp=temp/10;
sum=sum+(r*r*r);
}
if(sum==num)
printf("%d ",num);
}
return 0;
}
C
program for Armstrong number
generation
How
to find Armstrong number in c
Code
for Armstrong number in c
#include<stdio.h>
main()
{
int num,r,sum,temp,min,max;
printf("Enter the minimum range: ");
scanf("%d",&min);
printf("\nEnter the maximum range: ");
scanf("%d",&max);
printf("\nArmstrong numbers in given range are: ");
printf("\n");
for(num=min;num<=max;num++)
{
temp=num;
sum = 0;
while(temp!=0)
{
r=temp%10;
temp=temp/10;
sum=sum+(r*r*r);
}
if(sum==num)
printf("%d ",num);
}
return 0;
}
No comments:
Post a Comment