Armstrong Number

A Number is said to be an armstrong number if sum of cubes of its digits is equal to its number.


int main() {
  int k,sum=0,n1,n=371;
  n1=n;
  while(n!=0)
  {
    k=n%10;
    k=k*k*k;
    sum+=k;
    n=n/10;
  }
  if(sum==n1)
  {
    printf("The given number is armstrong number");
  }
  return 0;
}

Comments

Popular posts from this blog

Finding the second largest in an array