New Android apps UniqueKey

Saturday 7 March 2015

Armstrong number


/*check number is Armstrong number or not*/

#include<stdio.h>
#include<math.h>

main()
{
  int num,i,j,temp,sum=0,dig,n;

  printf("enter the number to check\n");
  scanf("%d",&num);

  for(temp=num;temp>0;)
  {
     dig=temp%10;
     sum=sum+(dig*dig*dig);
     temp=temp/10;
  }
  if(num==sum)
  {
   printf("number is a armstrong number\n");
  }
  else
   printf("number is not a armstrong number\n");

}

No comments:

Post a Comment