
C Program To Find & Print An Armstrong Number.
/* Declaration Of Header Files */
# include < stdio.h >
# include < conio.h >
/* Start Of Main Program */
void main()
{
/* Declaration Of Variables */
int Num = 0, s, r, t;
clrscr();
printf ( " \n Enter Any Number : " );
scanf ( " %d ", &Num );
t = Num;
s = 0;
while ( Num > 0 )
{
r = Num % 10;
s = s + ( r * r * r );
Num = Num / 10;
}
if ( s == t )
{
printf ( " \n %d Is An Armstrong Number.", t );
}
else
{
printf ( " \n %d Is Not An Armstrong Number.", t );
}
getch();
}
/* End Of Main Program */
Output :
Enter Any Number : 153
153 Is An Armstrong Number.
No comments:
Post a Comment