/*Write a C++ program to check whether the given number is an Armstrong Number. */
#include<iostream.h>
#include<conio.h>
void main( )
{
int n,sum,num,digit;
clrscr( );
cout<<"Enter the number"<<endl;
cin>>n;
num=n;
sum=0;
do
{
digit=n%10;
sum=sum+digit*digit*digit;
n=n/10;
}while(n!=0);
if(sum == num)
cout<<"it is an Armstrong Number "<<endl;
else
cout<<"it is not an Armstrong Number "<<endl;
getch( );
}

No comments: