Problem 64. C Program to print Armstrong number between 1-500(Process III).
#include<stdio.h>
#include<conio.h>
main( )
{
int i,n,s,r;
clrscr( );
for(i=1;i<=500;i++)
{
n=i;
s=0;
while(n>0)
{
r=n%10;
s=s+(r*r*r);
n=n/10;
}
if(i==s)
printf(“n%d”,s);
}
getch();
}
C compiler: gcc 4.1.2
Back to main directory: Sample C Program | Software Practical | Solved C Assignment#include<stdio.h>
#include<conio.h>
main( )
{
int i,n,s,r;
clrscr( );
for(i=1;i<=500;i++)
{
n=i;
s=0;
while(n>0)
{
r=n%10;
s=s+(r*r*r);
n=n/10;
}
if(i==s)
printf(“n%d”,s);
}
getch();
}
C compiler: gcc 4.1.2