Skip to content

Commit

Permalink
Armstrong Numbers in given interval
Browse files Browse the repository at this point in the history
  • Loading branch information
KeerthanaPravallika authored May 25, 2021
1 parent ccb8c76 commit 13831f3
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions Armstrong Numbers in given interval
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#include <stdio.h>

int main()
{
int start,end,i,tmp,d,sumOfCubes=0,num;
printf("Enter the interval : ");
scanf("%d ",&start);
scanf("%d",&end);
for(num = start;num<=end;num++)
{
sumOfCubes=0;
tmp = num;
while(tmp!=0)
{
d = tmp%10;
sumOfCubes = sumOfCubes + (d*d*d);
tmp = tmp/10;
}
if(num == sumOfCubes)
printf("%d is a Armstrong Number\n",num);
else
printf("%d is not a Armstrong Number\n",num);


}
return 0;
}

0 comments on commit 13831f3

Please sign in to comment.