Skip to content
This repository was archived by the owner on Nov 3, 2024. It is now read-only.

Created armstrong #458

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions Beginner Level πŸ“/Armstrong numbers/armstrong
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//armstrong is a number if the sum of cube of each element gives the same number e.g cude of 1,5,3 gives 153.

#include<iostream>
#include<math.h>
using namespace std;

int main( )
{
int n;
cin>>n;
int original = n;
int sum = 0;

while(n>0){
int lastdigit = n%10;// returns Remainder
sum+= lastdigit*lastdigit*lastdigit;// calculation and Addition of cube from last digit...
n=n/10;
}
if(sum==original){
cout<<"armstrong"<<endl;
}
else{
cout<<"not-armstrong"<<endl;
}
return 0;
}