armstrong lance code example
Example: armstrong
//examples = 370;371;153;407;
// made by Kashish Vaid the great
#include <stdio.h>
#include <math.h>
void main()
{
int i, num, result=0, remainder;
// applicable for 3 digits only
printf("Enter 3 digit number: ");
scanf("%d",&num);
for( i=num ; i != 0 ; i/=10)
{
remainder = i % 10;
result += remainder * remainder * remainder;
}
// if else shortcut
( (result == num) ? printf("%d is an Armstrong no.",num) : printf("%d isn't an Armstrong no.",num) );
}
// made by Kashish Vaid the great