C program to check whether the input digit is Armstrong or not
(An
Armstrong number of three digits is an integer such that the sum of the cubes
of its digits is equal to the number itself. For example, 371 is an Armstrong
number since 3^3+7^3+1^3=371)
#include<stdio.h>
#include<conio.h>
main()
{
int num,n,sum=0,d;
printf("Enter any
number\n");
scanf("%d",&n);
num=n;
do{
d=n%10;
sum=sum+d*d*d;
n=n/10;
}while(n>0);
if(sum==num)
printf("Armstrong
number\n");
else
printf("Not Armonstrong
number\n");
getch();
}
No comments:
Post a Comment