C Progranm to Check for Armstrong Number

Armstrong Number : When Sum of Cubes of Digits Of Number Equal to Same Given Number then the number is called as Armstrong Number.
#include<stdio.h>
int main()
{
int num,temp,sum=0,rem;

printf("nEnter Number For Checking Armstrong : ");
scanf("%d",&num);

temp = num;

 while (num != 0)
 {
  rem = num % 10;
  sum = sum + (rem*rem*rem);
  num = num / 10;
 }

if(temp == sum)
    printf("n%d is Amstrong Number",temp);
else
    printf("n%d is Amstrong Number",temp);
return(0);
}

Output :
Enter Number For Checking Armstrong : 153
153 is Amstrong Number
Explanation :
153 = [1*1*1] + [5*5*5] + [3*3*3]
    = 1 + 125 + 27
    = 153

Share this

Related Posts

:)
:(
hihi
:-)
:D
=D
:-d
;(
;-(
@-)
:P
:o
:>)
(o)
:p
:-?
(p)
:-s
(m)
8-)
:-t
:-b
b-(
:-#
=p~
$-)
(y)
(f)
x-)
(k)
(h)
cheer