Armstrong number is any number whose all digits cube's sum is the same number.
 If number is 153 then 1^3  + 5^3 +  3^3  = 153  So, these types of numbers are called as
 Armstrong number.
 so, through this program we will find whether the entered number is Armstrong or not.
 We will just cube all digits and sum them, then we will check it using if conditions that
  if the number is equal to sum number. If it's equal then it is Armstrong otherwise not.
    
  Program

  #include <stdio.h>
  #include <conio.h>
  void main()
  {
   int n,temp,cube,rem,sum=0;
   printf("Enter the number you want to check=");
   scanf("%d",&n);
   temp=n;
   for(n=temp ; n > 0 ;  )
    {
      rem=n%10;
      cube=rem*rem*rem;
      sum=sum+cube;
      n=n/10;
    }
   if(sum == temp)
    {
      printf("Number is Armstrong");
    }
  else
   {
     printf("number is not Armstrong");
   }
 }

 Output:  
 




Post a Comment

Previous Post Next Post