We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 2808129 commit 28c68c2Copy full SHA for 28c68c2
7Armstrong.cpp
@@ -0,0 +1,33 @@
1
+
2
3
+#include <bits/stdc++.h>
4
+using namespace std;
5
6
+int main() {
7
+ // Write C++ code here
8
+ // 153=1^3+5^3+3^3; is called armstrong number
9
+ int n;
10
+ cin>>n;
11
+ int num=n;
12
+ int arr[100];
13
+ int i=0;
14
+ while(n>0){
15
+ arr[i]=n%10;
16
+ n=n/10;
17
+ i++;
18
+ }
19
+ int sum=0;
20
+for(int j=i-1;j>=0;j--){
21
+ sum=sum+pow(arr[j],3);
22
+}
23
24
+cout<<sum;
25
+cout<<n;
26
+if(sum==num){
27
+ cout<<"yes";
28
29
+else{
30
+ cout<<"no";
31
32
+ return 0;
33
0 commit comments