C++ Program to Check Given Number Is Armstrong Number andrey воскресенье, 12 января 2014 г. No Comment

Today we are going to write a program in C++ to check a number is Armstrong number or not. Have a look at the definition of an Armstrong number: An Armstrong variety of 3 digits is AN whole number such the add of the cubes of its digits is capable the amount itself. for instance, 371 is AN Armstrong variety since 3**3 + 7**3 + 1**3 = 371. It means that an Armstrong Number is a three digit number such that sum of the cubes of all the digits of the number gives the same number.

#include
#include
#include
int main(void)
{
 clrscr();
 int n,m=0,x,y;
 cout<<"Enter any three digit numnber:";
 cin>>n;
 y=n;
 while(n!=0)
 {
  x=n%10;
  m+=pow(x,3);
  n=n/10;
 }
 if(y==m)
  cout<<"The number is an Armstrong number";
 else
  cout<<"The number is not an Armstrong number";
 getch();
return 0;
}
Today we are going to write a program in C++ to check a number is Armstrong number or not. Have a look at the definition of an Armstrong number: An Armstrong variety of 3 digits is AN whole number such the add of the cubes of its digits is capable the amount itself. for instance, 371 is AN Armstrong variety since 3**3 + 7**3 + 1**3 = 371. It means that an Armstrong Number is a three digit number such that sum of the cubes of all the digits of the number gives the same number.

#include
#include
#include
int main(void)
{
 clrscr();
 int n,m=0,x,y;
 cout<<"Enter any three digit numnber:";
 cin>>n;
 y=n;
 while(n!=0)
 {
  x=n%10;
  m+=pow(x,3);
  n=n/10;
 }
 if(y==m)
  cout<<"The number is an Armstrong number";
 else
  cout<<"The number is not an Armstrong number";
 getch();
return 0;
}
by Jillur Rahman

Jillur Rahman is a Web designers. He enjoys to make blogger templates. He always try to make modern and 3D looking Templates. You can by his templates from Themeforest.

Follow him @ Twitter | Facebook | Google Plus

No Comment