Showing posts with label Armstrong. Show all posts
Showing posts with label Armstrong. Show all posts

Wednesday, July 6, 2011

Program to find whether the given number is an Armstrong number.


An Armstrong Number is as follows:-


153 = 1^3 + 5^3 + 3^3 = 153


#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int no,num,sum=0;
cout<<"Enter the no."<<endl;
cin>>no;
num=no;
do
{
sum=sum+(no%10)*(no%10)*(no%10);
no=no/10;
}
while(no!=0);
if(sum==num)
cout<<"Amstrong"<<endl;
else
cout<<"Boo"<<endl;
getch();
}