C Program To Show Armstrong Number AT Given Range

#include <stdio.h>
int main()
{
    int r1,r2,t,sum,i,r,f=0,c=0;
    printf("Enter Range=\n");
    scanf("%d%d",&r1,&r2);
    printf("Among Range Armstrong Numbers Are\n");
    for(i=r1;i<=r2;i++)
    {
        t=i;
        sum=0;
        while(t!=0)
        {
            r=t%10;
            sum=sum+r*r*r;
            t=t/10;
        }
        if(i==sum)
        {
            printf("%d\n",i);
            c++;
            f=1;
        }


    }
     printf("Total Armstrong Numbers=%d\n",c);
    if(f!=1)
        printf("Not Found In This Range\n");
    return 0;

}

Download Coding Interview Book and Get More Tutorials for Coding and Interview Solution: Click Here

Download System Design Interview Book and Get More Tutorials and Interview Solution: Click Here

Do you need more Guidance or Help? Then Book 1:1 Quick Call with Me: Click Here

Share on Google Plus

About Ashadullah Shawon

I am Ashadullah Shawon. I am a Software Engineer. I studied Computer Science and Engineering (CSE) at RUET. I Like To Share Knowledge. Learn More: Click Here
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment