#include <stdio.h>
#include <stdlib.h>
int main()
{
/*An Armstrong number is a number such that the sum
of its digits raised to the third power is equal to the number
itself. For example, 371 is an Armstrong number, since
3^3 + 7^3+ 1^3 = 371.*/
int a, n, b = 0, t;
printf("Enter the no: ");
scanf("%d", &n);
t = n;
while (n > 0)
{
a = n % 10;
b = b + a * a * a;
n = n / 10;
}
if (b == t)
{
printf("Its an Armstrong number");
}
else
{
printf("Its Not an Armstrong number");
}
getch();
return 0;
}
/*-via Programming Hub for Android, a top rated Programming App on Google Play
https://play.google.com/store/apps/details?id=com.freeit.java*/
Sunday, August 16, 2015
Program: Armstrong Number
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment