An Armstrong number is a three digits( 0-999 ) integer number,each digit cubes of the sum is equal to the number itself. Armstrong numbers : 0,1,153,370,371,407.
Example : " ^ " power sign . e.g : 2^3=2*2*2=8
Example : " ^ " power sign . e.g : 2^3=2*2*2=8
- 0^3=0
- 1^3=1
- 1^3+5^3+3^3=153
- 3^3+7^3+0^3=370
- 3^3+7^3+1^3=371
- 4^3+0^3+7^3=407
Program :
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
int n,b,am=0,c,d,p,e;
char ch;
do{
clrscr();
printf("\n\t Enter no(0-999):");
scanf("%d",&n);
d=e=n;
for(b=0;n>0;b++)
{
n=n/10;
}
while(d>0)
{
c=d%10;
p=pow(c,b);
am=am+p;
d=d/10;
}
if(am==e)
printf("\n\t <%d> Armstrong Number",e);
else
printf(" \n\t<%d> Not Armstrong Number",e);
printf("\n\t Continue(y/n) :");
ch=getch();
}while(ch=='Y'||ch=='y');
}
If you have any Further Information and Quires about this Article don't hesitate to comment in comment box below.
AND
If you like this article , like our Facebook like page and click +1 to support 123techguide
|