Write a C program to display Armstrong nos between 1 to 500

#include <stdio.h>
#include <conio.h>
void main()
{
int n=1,dum,sum=0,r;
clrscr();
printf("Armstrong nos between 1 to 500/n");
while (n<=500)
{
dum=n;
while (dum>0)
{
r=dum%10;
sum=sum+(r*r*r);
dum=dum/10;
 }
if(sum==n)
  printf("\n\n%d",sum);
  n=n+1;
  sum=0;
}
 getch();

2 comments:

Related Post

Array:
String functions:
General (Loops-for/while)
Write a Program to print reverse of a given number Write a Program to print Product of Digits (eg. 212=2*1*2=4) of a given number Write a C++ Program to Convert Binary into Decimal Number