Armstrong number using c program
What is 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. For example, 371 is an Armstrong number since 3**3 + 7**3 + 1**3 = 371.
#include<stdio.h> #include<conio.h> main() { int num,temp,sum=0,rem; printf("Enter number for checking Armstrong"); scanf("%d",&num); temp=num; while(num!=0){ rem=num%10; sum=sum+(rem*rem*rem); num=num/10; } if(temp==sum) printf("%d is an armstrong number",temp); else printf("%d is not an armstrong number",temp); getch(); }
Output
screenshot for Armstrong number checking |
If you found any problem in any problem or you have any question regarding program don't forget to leave a message in below comment box
No comments