Program that check an Armstrong number
A program that input a number and check whether the number is an Armstrong number or not:
using namespace std;
#include<iostream>
#include<conio.h>
int main()
{
int number,n,r,sum;
cout<<"Enter a number:";
cin>>number;
n=number;
sum=0;
while(n!=0)
{
r=n%10;
sum=sum+(r*r*r);
n/=10;
}
if(sum==sum)
cout<<number<<" is Armstrong";
else
cout<<number<<" is not Armstrong";
getch();
return 0;
}
Program that check an Armstrong number
Reviewed by Alpha
on
3/25/2017 09:49:00 am
Rating:
No comments: