source file name: armstrong.c
#include <stdio.h>
int main()
{
int n,d1,d2,d3;
int sum=0,temp;
//clrscr();
printf("\n enter any 3 digit number: ");
scanf("%d",&n);
temp=n;
d1=n%10;
n=n/10;
d2=n%10;
n=n/10;
d3=n%10;
sum=(d1*d1*d1)+(d2*d2*d2)+(d3*d3*d3);
if(sum==temp)
printf("\n given no is Armstrong no ");
else
printf("\n given no is not Armstrong no ");
//getch();
return 0;
}
output:
1. enter any 3 digit number: 170
given no is not Armstrong no
2. enter any 3 digit number: 153
given no is Armstrong no
0 Comments
Post a Comment