Armstrong number

Q. Write a program to check whether a number is a Armstrong number or not.


Definition of Armstrong number: An Armstrong number of three digits is an integer such that the sum of the cubes of its digits is equal to the number itself.
In other word “A number is Armstrong if it is equal the sum of cube of its digits.”
Example of Armstrong number is 371 because according to definition cube of its digits  sum will be equal to number so
Armstrong number 371=(3)3+(7)3+(1)3

/*program to check whether a number is Armstrong or not*/
int main()
 int n,num,rem,sum=0;
 printf("Enter any number : ");
 scanf("%d", &num);
 for(n=num; n>=1; n=n/10)
    printf("Number is Armstrong number");
    printf("Number is not Armstrong number");
 return 0;


Enter any number :254
Entered number is not Armstrong number
Enter any number : 371
Entered number is Armstrong number

Related Program:
  1. Amicable number C program
  2. Flowchart for checking number is Armstrong or not
  3. Perfect number C program
  4. Print Armstrong number range C program

No comments:

Post a Comment

Post a Comment