why my program is not giving correct output:
#include
#include
using namespace std;
int num;
int count=0;
int newnum=0;
void checkArmstrong(int n){
int oldnum=n;
num=n;
while(num>0){
num=num/10;
count++;
}
int p=count;
while(n>0){
int x=n%10;
newnum=pow(x,p)+newnum;
n=n/10;
}
if(newnum==oldnum){
cout<<newnum<<endl;
}
}
int main(){
int num1,num2;
cin>>num1>>num2;
for( int i=num1;i<=num2;i++){
checkArmstrong(i);
}
return 0;
}