***ARMSTRONG NUMBER CHECKING***
Code:
#include<stdio.h>
#include<conio.h>
void main()
{
int a,d,b,c=0,e;//i'm getting output for 4digit nos and less
clrscr();//i want output for 5 digits and more
printf("Enter the number\n");//i used long but the o/p is wrong
scanf("%d",&a);//I think i dont get something correct for my wants
d=a;//someone help me
e=nod(a);
do
{
b=a%10;
c+=pwr(b,e);
a=a/10;
}while(a>0);
if(c==d)
printf("%d is an armstrong number\n",c);
else
printf("%d is not an armstrong number",d);
getch();
}
pwr(int a,int b)
{
int c,d;
c=1;
for(d=0;d<b;d++)
{
c=c*a;
}
return(c);
}
int nod(int a)
{
int c=0;
while(a>0)
{
c++;
a=a/10;
}
return(c);
}
Comment