C++ Program for Armstrong Number
Master C++ with Real-time Projects and Kickstart Your Career Start Now!!
Program 1
// Program for Armstrong
// A number whos some of qube of individual digit is equal to number
#include<iostream>
#define clrscr() system("cls")
using namespace std;
int main()
{
int n,r,sum,m,i=1;
clrscr();
// cout<<"Enter a number";
// cin>>n;
while(i<=500)
{
sum=0;
n=i;
m=n;
while(n!=0)
{
r=n%10;
sum=sum+(r*r*r);
n=n/10;
}
if(m==sum)
//cout<<"No is armstrong";
cout<<m<<endl;
// else
// cout<<"No is not armstrong";
i++;
}
}
Did you know we work 24x7 to provide you best tutorials
Please encourage us - write a review on Google

