#include(conio.h)
int main( )
{
int no, temp, rem, sum;
clrscr( );
printf("Armstrong numbers between 1 and 1000 are:\n");
for(no=1; no<=1000; no++)
{
temp=no;
sum=0;
while(temp>0)
{
rem=temp%10;
sum=sum+(rem*rem*rem);
temp=temp/10;
}
if(no==sum)
printf("\n%d", no);
}
getch( );
return 0;
}
Output:
Armstrong numbers between 1 and 1000 are:
1
153
370
371
407
Its really quiet helpful as i a new learner i t helps me a lot
ReplyDeletegood
ReplyDeleteI suppose Armstrong number are
ReplyDeleteSum of their own digits to the power of the number of digits
So
1,2,3,4,5,6,7,8,9
All are Armstrong
Yes u are right...
DeleteThis answer is wrong
the power is only 3(cube) and nothing else,,,:)
ReplyDeletehow to print total number.like here total number is 5
ReplyDeleteThis comment has been removed by the author.
ReplyDelete#include(stdio.h)
Delete#include(conio.h)
int main( )
{
int no, temp, rem, sum,count=0;
clrscr( );
printf("Armstrong numbers between 1 and 1000 are:\n");
for(no=1; no<=1000; no++)
{
temp=no;
sum=0;
while(temp>0)
{
rem=temp%10;
sum=sum+(rem*rem*rem);
temp=temp/10;
}
if(no==sum)
{
printf("\n%d", no);
count++;
}
}
printf("%d",count);
getch( );
return 0;
}
What's the output?
DeleteSimply super
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteArmstrong program in C
ReplyDeletenice
This comment has been removed by the author.
ReplyDeletewow sipmle logic...awesome
ReplyDeleteWhat's the tem and temp plz suggest me
ReplyDeleteTemp means another variable to store the n variable,rem is remainder,😆
DeleteI SO HAPPY
ReplyDelete