stay in the same value of analog input give output one time

Ah, I placed the else in the wrong scope. Try:

const int sensor = A0; // analog input use variable resistance
int flagged = 0;  // create a flag variable

void setup ()
{
  Serial.begin (9600);
}

void loop ()
{
  if(analogRead(sensor)==1023)//when variable resistance give value =1023 print 'x' 
  { 
   if(!flagged)   // if already printed out an x, don't repeat unless a less then 1023 reading has occured
    {
      Serial.print("x");
      Serial.println();
      flagged = 1;      // set flag to note the we have printed an x on first new reading of a 1023 value
    }
   
  }
  else flagged =0;  // we read a value less then 1023 so clear flag so next time a 1023 will print an x
  
 delay (1000);
}