ARMSTRONG NUMBERS USING C


To write a c program to find the Armstrong numbers using for loop.



/*ARMSTRONG NUMBERS*/
#include<stdio.h>
#include<conio.h>
void main()
{
int i,sum,n,d;
clrscr();           
printf("armstrong number series from 100 and 1000");
for(i=100;i<1000;i++)
{         
n=i;
sum=0;
while(n!=0)
{
d=n%10;
n=n/10;
sum=sum+d*d*d;
}
if(sum==i)
printf("\n%d",i);
}
getch();
}

OUTPUT:

            Armstrong number series from 100 and 1000
153
370
371
407
 

Comments

Post a Comment

Popular posts from this blog

TRAVELING SALESMAN USING BRANCH AND BOUND TECHNIQUE

BOOKS DETAILS USING C STRUCTURE

TRAVELING SALESMAN USING BRANCH AND BOUND TECHNIQUE