Wednesday, 27 February 2013

Armstrong Program


By on 02:27

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.


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.

0 comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...