Armstrong Numbers upto N

Armstrong Numbers upto N

Welcome to the World of Online Learning:

Hello Friends “This blog helps you to learn C programming concepts. You can learn C language at your own speed and time. One can learn concepts of C language by practicing various programs given on various pages of this blog. Enjoy the power of Self-learning using the Internet.”

Armstrong Numbers upto N
Armstrong Numbers upto N

Write a C program to Armstrong Numbers upto N

PROGRAM: Armstrong Numbers upto N

/* Print Armstrong Numbers upto N */

#include<stdio.h>

int main()
{
    int i,j,sum,n;

    printf(“Please enter the value of N: “);
    scanf(“%d”,&n);
   
    for(i=2;i<=500;i++)
    {
        for(j=i,sum=n;j>=1;j=j/10)
            sum=sum+(j%10)*(j%10)*(j%10);
        if(sum==i)
            printf(“%d is Armstrong.\n”,i);
    }
    return 0;
}

Leave a Reply

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