Hi I am very new to c++ programming.I am just trying to check whether the number is Armstrong number. Please see my code below.
This program works fine for all the numbers but when I give 153, which is Armstrong number is getting printed as not an Armstrong number.
Also armstrong=armstrong+pow((temp%10),counter); gets evaluated as 124 instead of 125 for 5^3.
Eventhough I have found better methods now. I still want to know why this code isn't working.
using namespace std;
int armstrong(int n)
int temp =n;
cout << "Enter the number to check!" << endl;
cin >> n;
cout << "The number is armstrong"<< endl;
cout<< "The number is not armstrong"<<endl;