Write A C Program To Check Number Is Armstrong Or Not using While Loop
Armstrong Number : An Armstrong number of three digits is an integer such that the sum of the cubes of its digits is equal to the number itself. For example, 371 is an Armstrong number since 3**3 + 7**3 + 1**3 = 371
Logic :
Logic is very simple you have to you have to separate all digit and Find The sum of the cube of digit .
Example : let's check 371 then divide by 10 we got 371/10=1 .cube of 1 is 1 store this result and again divide by 10 we got 37/10=7 . cube of 7 is 343 store and add to previously got result 1 so now its become 344 ,again divide by 10 we got 3/10=3 cube of 3 is 27 ,Now again add 27+344=371
so the Number is Armstrong Number
Note :Divide the number by 10 until it become Zero
Output:
Enter A Positive Integer To Check For Armstrong:
153
153 Is An Armstrong Number
Enter A positive Integer To Check For Armstrong:
135
135 Is Not An Armstrong Number
Enter A positive Integer To Check For Armstrong:
001
1 Is Not An Armstrong Number
need an explanation for this answer? contact us directly to get an explanation for this answer