Using this program user can check whether number is Armstrong using While Loop.If sum of cubes of each digit of number is equal to entered number, then the number is called an Armstrong number.
Eg:- 153=(1*1*1)+(5*5*5)+(3*3*3)
Program:
#include<stdio.h>
#include<conio.h>
void main()
{
int number,sum=0,n,temp;
printf("Enter The Number\n");
scanf("%d",&number);
temp=number;
while(number!=0)
{
n=number%10;
number=number/10;
sum=sum+(n*n*n);
}
if(sum==temp)
{
printf("%d is Armstrong Number",sum);
}
else
{
printf("%d is Not Armstrong Number",sum);
}
getch();
}
Output:
No comments:
Post a Comment
Feel free to ask us any question regarding this post