/*153 = 1*1*1 + 5*5*5 + 3*3*3 // 153 is an Armstrong number.*/
#include<stdio.h>
#include<conio.h>
main( )
{
int number, originalNumber, remainder, result = 0;
clrscr( );
printf (" Enter a Three Digit Number:");
scanf ("%d", &number);
originalNumber=number;
while(originalNumber!=0)
{
remainder=originalNumber%10;
originalNumber=originalNumber/10;
result=result+remainder*remainder*remainder;
}
if (result==number)
printf ("The Given Number is Armstrong number");
else
printf ("The Given Number is Not Armstrong number");
getch( );
}
Output:
Run-1
Run-2
Previous Next
No comments:
Post a Comment