Comparing charAt and integer not working

I have this problem where i am trying to compare the result of charAt with integers named pOne, pTwo, pThree, pFour and i get a result of incorrect password every time. Even know when i change pOne, pTwo, pThree, pFour with 49, 50 ,51 ,52 it works with the numbers in place but not the integers. Here is my code

String num;
int times;
int ren;
int state;
int attempts;
int rep;
int pOne;
int pTwo;
int pThree;
int pFour;
void setup(){
  Serial.begin(9600);
  int state = 0;
  int ren = 0;
  int rep = 0;
  int times = 0;
  num = "0";
  int pOne = 49;
  int pTwo = 50;
  int pThree = 51;
  int pFour = 52;
  int attempts = 0;
  Serial.println("enter your password");
}
void loop(){
  int in = analogRead(A0);
  if(in > 3){
    if(in < 10){
      num = num + "1";
      times = times + 1;
    }
  }
  if(in > 510){
    if(in < 514){
      num = num + "2";
      times = times + 1;
    }
  }
  if(in > 999){
    if(in < 1004){
      num = num + "3";
      times = times + 1;
    }
  }
  if(in > 1020){
    if(in < 1024){
      num = num + "4";
      times = times + 1;
    }
  }
  while(analogRead(A0) > 0){
    delay(10);
  }
  while(times >= 4){
    if(num.charAt(1) == pOne){
      if(num.charAt(2) == pTwo){
        if(num.charAt(3) == pThree){
          if(num.charAt(4) == pFour){
            num = "0";
            state = 1;
            times = 0;
            attempts = 0;
            Serial.println("unlocked");
          }
          else{
            Serial.println("incorrect password");
            attempts = attempts + 1;
            num = "0";
            times = 0;
          }
        }
        else{
          Serial.println("incorrect password");
          attempts = attempts + 1;
          num = "0";
          times = 0;
        }
      }
      else{
        Serial.println("incorrect password");
        attempts = attempts + 1;
        num = "0";
        times = 0;
      }
    }
    else{
      Serial.println("incorrect password");
      attempts = attempts + 1;
      num = "0";
      times = 0;
    }
  }
  if(attempts >= 4){
    Serial.println("the device is locked out");
    attempts = 0;
    delay(300000);
    Serial.println("the device is ready");
  }
  if(state == 1){
    Serial.println("do you want to make a new password?");
    Serial.println("if so press 1");
    Serial.println("to exit and lock the device hit 3");
    ren = 1;
  }
  while(ren == 1){
    int goo = analogRead(A0);
    if(goo > 999){
      if(goo < 1004){
        state = 0;
        ren = 0;
        Serial.println("enter your password");
      }
    }
    if(goo > 3){
      if(goo < 10){
        Serial.println("the device has entered password reprogramming");
        rep = 1;
        ren = 0;
      }
    }
  }
  while(rep == 1){
    while(analogRead(A0) > 0){
    }
    Serial.println("enter your first digit");
    while(analogRead(A0) < 4){
    }
    int pVar = analogRead(A0);
    if(pVar > 3){
      if(pVar < 10){
        pOne = 49;
      }
    }
    if(pVar > 510){
      if(pVar < 514){
        pOne = 50;
      }
    }
    if(pVar > 999){
      if(pVar < 1004){
        pOne = 51;
      }
    }
    if(pVar > 1020){
      if(pVar < 1024){
        pOne = 52;
      }
    }
    while(analogRead(A0) > 0){
    }
    Serial.println("enter your second digit");
    while(analogRead(A0) < 4){
    }
    pVar = analogRead(A0);
    if(pVar > 3){
      if(pVar < 10){
        pTwo = 49;
      }
    }
    if(pVar > 510){
      if(pVar < 514){
        pTwo = 50;
      }
    }
    if(pVar > 999){
      if(pVar < 1004){
        pTwo = 51;
      }
    }
    if(pVar > 1020){
      if(pVar < 1024){
        pTwo= 52;
      }
    }
    while(analogRead(A0) > 0){
    }
    Serial.println("enter your third digit");
    while(analogRead(A0) < 4){
    }
    pVar = analogRead(A0);
    if(pVar > 3){
      if(pVar < 10){
        pThree = 49;
      }
    }
    if(pVar > 510){
      if(pVar < 514){
        pThree = 50;
      }
    }
    if(pVar > 999){
      if(pVar < 1004){
        pThree = 51;
      }
    }
    if(pVar > 1020){
      if(pVar < 1024){
        pThree = 52;
      }
    }
    while(analogRead(A0) > 0){
    }
    Serial.println("enter your last digit");
    while(analogRead(A0) < 4){
    }
    pVar = analogRead(A0);
    if(pVar > 3){
      if(pVar < 10){
        pFour = 49;
      }
    }
    if(pVar > 510){
      if(pVar < 514){
        pFour = 50;
      }
    }
    if(pVar > 999){
      if(pVar < 1004){
        pFour = 51;
      }
    }
    if(pVar > 1020){
      if(pVar < 1024){
        pFour = 52;
      }
    }
    while(analogRead(A0) > 0){
    }
    Serial.println("the reprogramming is done");
    rep = 0;
  }
  delay(10);
}

what do you mean, it works with the numbers but not with the integers ?

What are you trying to do? My guess is you want a something like a combination lock that uses a potentiometer. I'm guessing that a pot is the mystery device at pin A0. But I can only guess.

The global variables, pOne, pTwo, etc. are initialized to 0. The local variables of the same names in setup() are useless. Get rid of the int keyword in setup() to initialize the global variables. Or, just do the initialization when you declare the global variables. Declaration and initialization do not have to be separate steps.