Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //C program to check whether a number is Armstrong number or not.
- #include <stdio.h>
- int main()
- {
- int x,sum=0,LN,num;
- printf("Enter a number: ");
- scanf("%d",&x);
- num=x;
- while(num>0){
- LN=num%10;
- sum+=(LN*LN*LN);
- num=num/10;
- }
- if(sum==x)
- printf("%d is an Armstrong number.",x);
- else
- printf("%d is not an Armstrong number.",x);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment