C program for Armstrong Number | Armstrong Number Program Logic

Spread the love
ARMSTRONG NUMBER : An Armstrong number of an integer such that the sum of the cubes of its digits is equal to the number itself.
For example, 371 is an Armstrong number since 3**3 + 7**3 + 1**3 = 371.

/************* Program ****************/

#include<stdio.h>
void main()
{
     int n,temp,rem,arm;
     arm = 0;
     printf(“Enter no : “);
     scanf(“%d”,&n);
     temp = n;
     while(temp>0)
     {
      rem = temp %10;
      arm = arm + (rem*rem*rem);
      temp = temp/10;
     }
     if(arm == n)
     {
      printf(“Given Number is Armstrong Number n”)
     }
     else
      printf(Not Armstrong Number…n”);
}

/***************** OUTPUT **************/


Venkatesh Macha

Hi Guys, I am Venkatesh Macha. I am a programmer and an Open Source enthusiast, Presently working as a Software Engineer. Apart from that, I love to explore new technologies and things.

You may also like...

Leave a Reply