Welcome..!!

Please visit http://csprograms.in/ for more Computer Science programs.

Showing posts with label armstrong. Show all posts
Showing posts with label armstrong. Show all posts

Tuesday, 13 March 2012

6. C++ program to find Armstrong number


#include <iostream>
int main()
{
int s, n, m, r;
cout <<"Enter the number \n";
cin >>n;
cout <<" Entered number is \n"<< n;
s=0;
m=n;
do
{
r=n%10;
n=n/10;
s=s+r*r*r;
}while (n!=0);
if(s==m)
cout <<"This is Armstrong number\n";
else
cout <<"This is not Armstrong number\n";
return 0;
}