recent

C Programs To Check Number Is Armstrong or not

C Programs To Check Number Is Armstrong or not

#include<stdio.h>

int main()
{

int num, temp, sum = 0, rem;

   printf("Enter number for checking Armstrong :\n");
   scanf("%d", &num);  //input from user

   temp = num;  //temporary store num in temp variable

   while (num != 0)
   {
      rem = num % 10;
      sum = sum + (rem * rem * rem);  //by this while loop and method ypu cancheck whether number palindrome or not
      num = num / 10;
   }

   if (temp == sum)
      printf("%d is Amstrong Number\n", temp);   //Print Output On screen
   
   else
      printf("%d is Amstrong Number\n", temp);   //Print Output On screen

}
Powered by Blogger.