About:
A positive integer is called an Armstrong number (of order n) if
abcd...=an+bn+cn+dn+.....
In the case of an Armstrong number of 3 digits, the sum of cubes of each digit is equal to the number itself. For example, 153 is an Armstrong number because
153=1*1*1+5*5*5+3*3*3
Program:
A positive integer is called an Armstrong number (of order n) if
abcd...=an+bn+cn+dn+.....
In the case of an Armstrong number of 3 digits, the sum of cubes of each digit is equal to the number itself. For example, 153 is an Armstrong number because
153=1*1*1+5*5*5+3*3*3
Program:
#include<stdio.h>
void main()
{
int a,n,s=0,l;
printf("Enter any three-digit no:");
scanf("%d",&n);
int b=n;
while(n){
a=n%10;
s=s+(a*a*a);
n=n/10;
}
if(b==s)
printf("Given number is Armstrong");
else
printf("Not Armstrong number");
}
No comments:
Post a Comment