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>
Program to check whether number is an Armstrong or Notint 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 Program that check an Armstrong number Reviewed by Shoaib Jameel on 3/25/2017 09:49:00 am Rating: 5

No comments:

Ad

Propellerads
Theme images by mariusFM77. Powered by Blogger.