Program of Armstrong Number: Armstrong no. like 153 = (1*1*1)+(5*5*5)+(3*3*3). Q)Write a program in c language to enter a value and ch...
Program of Armstrong Number:
Armstrong no. like 153 = (1*1*1)+(5*5*5)+(3*3*3).
Q)Write a program in c language to enter a value and check the number is Armstrong or not.
Note:-You can also create this program in java,c#,c++(c plus plus) etc. with the same logic.
Armstrong no. like 153 = (1*1*1)+(5*5*5)+(3*3*3).
Q)Write a program in c language to enter a value and check the number is Armstrong or not.
Note:-You can also create this program in java,c#,c++(c plus plus) etc. with the same logic.
P:#include<stdio.h>
void main()
{
int s,n,d;
printf("enter no.");
scanf("%d",&n);
s=0,a=n;
while(n!=0)
{
d=n%10;
s=s*d*d*d;
n=n/10;
}
if(a==s)
printf("Number is Armstrong");
else
printf("Number is not Armstrong");
getch();
}
If you have any query then leave your comments and don't forgot to follow me on Google+,Facebook,Twitter.
COMMENTS