My issue
ol.cpp: In function ‘int main()’:
sol.cpp:6:4: error: ‘cin’ was not declared in this scope; did you mean ‘sin’?
6 | cin>>n;
| ^~~
| sin
sol.cpp:22:12: error: ‘cout’ was not declared in this scope
22 | cout<<“Armstrong”;
| ^~~~
sol.cpp:24:9: error: ‘cout’ was not declared in this scope
24 | else cout<<“Not Armstrong”;
| ^~~~
My code
#include <stdio.h>
#include <math.h>
int main() {
int n;
cin>>n;
int original_number = n;
int no_of_digits = 0;
while(n!=0){
n = n/10;
no_of_digits = 0;
}
n = original_number;
int sum = 0;
while(n!=0){
int last_digit = n%10;
sum += pow(last_digit, no_of_digits);
n = n/10;
}
if(sum==original_number){
cout<<"Armstrong";
}
else cout<<"Not Armstrong";
}
Learning course: Roadmap to 3*
Problem Link: https://www.codechef.com/learn/course/klu-roadmap-3star/KLURMP300B/problems/LPYAS151