#include "conio.h"
void main ()
{
int a,b;
int armstrong(int);
clrscr();
printf ("Enter a number: ");
scanf ("%d",&a);
b=armstrong (a);
if (b==1)
printf ("The number is armstrong");
else
printf ("The number is not armstrong");
getch ();
}
int armstrong (int x)
{
int q,r,m,R;
clrscr ();
m=x;
for (R=0;x>0;)
{
q=x/10;
r=x%10;
R=R+(r*r*r);
x=q;
}
if (R==m)
R=1;
else
R=0;
return (R);
}
0 comments:
Post a Comment