For this we have to be clear about what the armstrong number is:
I will make clear about it by the help of example:
For example: 153 is armstrong number because 1^3*5^3*3^3 is 153 itself. So if the summation of the entered number is the number itself then it is called armstrong number.
The main source code of this programme is given below:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
#include<conio.h> | |
int main() | |
{ | |
int r,n, num,c,sum; | |
printf("enter any number"); | |
n=num; | |
sum=0; | |
while(n>0) | |
{ | |
r=n%10; | |
c=r*r*r; | |
sum=sum+c; | |
n=n/10; | |
} | |
if(num==sum) | |
{ | |
printf("the no is armstrong");} | |
else | |
{ | |
printf("the no is not armstrong"); | |
} | |
getch(); | |
} |
0 comments :
Post a Comment