C Programming
Computer Programming

Program in c to Check Armstrong Number



Write a Program in c to Check Armstrong Number

\* C Program to to Check Armstrong Number *\

# include < stdio.h >
int   main( )
{

int   num, dig, sum, temp, cube  ;
printf(" Enter the Number : ") ;
scanf("%d ", & num) ;
sum = 0 ;
temp = num ;
do
{

dig = num % 10 ;
num = num / 10 ;
cube = dig * dig * dig ;
sum = sum + cube ;

}
while (   num   >   0 ) ;
if( sum == temp )
printf("\n Entred Number is Armstrong Number !! ") ;
else
printf("\n Entred Number is not a Armstrong Number !! ") ;
return ( 0 ) ;

}

Output of Program :

Output of Program in C to Check Armstrong Number