Monday , September 25 2017
Home / c-program / C Program – Armstrong numbers between given numbers

C Program – Armstrong numbers between given numbers

C Program  to print Armstrong numbers between the given two numbers.

Armstrong numbers :


#include<stdio.h> 
int main(void) 
{ 
    int x,y,n,num,cube,d,sum;
    printf("Enter x and y values to print Armstrong numbers: \n"); 
    scanf("%d%d",&x,&y); 
    printf("Armstrong numbers are :\n"); 
 
    for(num=x; num<=y; num++)     
    { 
        n=num; 
        sum=0; 
        while(n>0)     
        { 
            d=n%10; 
            n/=10; 
            cube=d*d*d; 
            sum=sum+cube; 
        } 
        if(num==sum)     
            printf("%d\n",num); 
    } 
    return 0; 
}

Enter x and y values to print Armstrong numbers:
50
1500
Armstrong numbers are :
153
370
371
407

Happy Learning 🙂

About chandrashekhar

Hi Folks, you have reach this so far, that shows you like what you are learning. Then why don't you support us to improve for bettor tutorials by leaving your valuable comments and why not you keep in touch with us for latest updates on your favorite blog @ facebook , twitter , Or Google+ ,

Recommended

C Program to add elements of an array

How to add elements in an array using C Program. Add elements of an Array …

Leave a Reply

Your email address will not be published. Required fields are marked *