Armstrong Number
An armstrong number is the number whose sum of the cubes of the digits is the number itself e.g. 153 1^3+5^3+3^3 = 1+125+27=153
/*
http://www.ProbCOMP.com
An armstrong number is the number whose sum of the cubes of the digits is the number itself
e.g. 153 1^3+5^3+3^3 = 1+125+27=153
*/
#include<stdio.h>
void armstrong(int num)
{
int sum=0,t,val;
t=num;
while(num>0)
{
val=num%10; // gives remainder
sum=sum+val*val*val;
num=num/10; // gives the number excluding the remainder
}
if(t==sum)
printf("%d is an armstrong number",t);
else
printf("%d is not an armstrong number",t);
}
void main()
{
int num;
printf("enter the number: ");
scanf("%d",&num);
armstrong(num);
}
Download Program


