Question : Write a C Program to check whether a number is Armstrong or not.
#include <stdio.h>
int main()
{
int n,r,sum=0,temp;
printf("enter the number=");
scanf("%d",&n);
temp=n;
while(n>0)
{
r=n%10;
sum=sum+(r*r*r);
n=n/10;
}
if(temp==sum)
{
printf("armstrong number ");
}
else
{
printf("not armstrong number");
}
return 0;
}
OUTPUT :
enter the number=153
armstrong number
Thank you very much for reading carefully, if you have any other questions, you can share it with us through comments, if this information was important to you, please let us know through comments.
Please do comment and share.
Thank You.
Please do comment and share.
Thank You.
No comments:
Post a Comment