C++ Program to display Armstrong number between 1 to 1000
#include<iostream.h>
#include<conio.h>
void main()
{
int arm=0;
int cube,rem,temp,i;
clrscr();
cout<<"Program to display Armstrong no. b/w 1 to 1000:\n";
for(i=1;i<=1000;i++)
{
temp=i;
arm=0;
while(temp!=0)
{
rem=temp%10;
temp=temp/10;
arm=arm+(rem*rem*rem);
}
if(arm==i)
cout<<arm <<" ";
}
getch();
}
No comments:
Post a Comment