Skip to content

Commit

Permalink
Merge pull request #1 from Meghna2080/Meghna-branch
Browse files Browse the repository at this point in the history
Create Check_armstrong_number.cpp
  • Loading branch information
Meghna2080 committed Oct 17, 2020
2 parents 9045b6f + 0ad6768 commit 328bd1c
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions Program's_Contributed_By_Contributors/Check_armstrong_number.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include<iostream>
#include<math.h>
using namespace std;

int main()
{
int n,temp,remainder,x=0,ans=0;
cout<<"Enter a number:"<<endl;
cin>>n;
temp=n;
while(temp!=0){
temp=temp/10;
x++;
}
temp=n;
while(temp!=0)
{
remainder=temp%10;
int power=round(pow(remainder,x));
ans+=power;
temp=temp/10;
}
if(ans==n)
cout<<"Armstrong number";
else
cout<<"Not an armstrong number";
return 0;
}

0 comments on commit 328bd1c

Please sign in to comment.