Print armstrong number unable to find error in my program

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;

}

@shivamraj53.sr, your code was almost correct u just missed 1 thing ive commented check the code for armstrong https://ide.codingblocks.com/s/656872

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.