#include <stdio.h>
#include <stdlib.h>
int main()
{
int i,n,a=0,b=0,sum=0;
printf("enter the limit of amstrong number: ");
scanf("%d",n);
for(i=1;i<=n;i++)
{
a=i;
while(a>0)
{
b=n%10;
sum=sum+ b*b*b;
a=a/10;
}
if(sum==i)
{
printf("%d",sum);
}
}
return 0;
}
it prints no errors but doest not work properly
rithish
13
Junior Poster in Training
Recommended Answers
Jump to PostYour code won't compile with that extra meaningless text at bottom of the program.
Jump to PostLine 26. Your program can't compile with that line in it.
And if that's supposed to be a question, after 200+ posts you'd think you'd know better than to simply say "it doesn't work" and let us try to figure out what that means.
All 8 Replies
WaltP
2,905
Posting Sage w/ dash of thyme
Team Colleague
rithish
13
Junior Poster in Training
WaltP
2,905
Posting Sage w/ dash of thyme
Team Colleague
rithish
13
Junior Poster in Training
WaltP
2,905
Posting Sage w/ dash of thyme
Team Colleague
rithish
13
Junior Poster in Training
poornamoksha
0
Newbie Poster
Gonbe
32
Newbie Poster
WaltP
commented:
Then why did you bather doing his moework for him in the first place?
-3
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.