For this in this programme I have taken n1 as 100 and n2 as 2000. You can take any positive number in place of n1 and n2. If you want to be more clear
you have to see the source code of this programme:
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 num,c,n,r,sum; | |
printf("the armstrong number between 100 to 2000 are\n"); | |
for(num=200;num<=2000;num++){ | |
n=num; | |
sum=0; | |
while(n>0) | |
{ | |
r=n%10; | |
c=r*r*r; | |
sum=sum+c; | |
n=n/10;} | |
if(num==sum) | |
printf("\t%d",num); | |
} | |
getch(); | |
return 0; |
0 comments :
Post a Comment