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

retrolefty:
You just need to keep track of past reading through the main loop:

const int sensor = A0; // analog input use variable resistance

int flagged = 0;

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

void loop ()
{
 if(analogRead(sensor)==1023)//when variable resistance give value =1023 print 'x'
 {
  if(!flagged)
   {                            // i need to add if condition here and when it valid print "X"  , my problem: when i add if condition not print "x"
     Serial.print("x");
     Serial.println();
     flagged = 1;
   }
  else flagged =0;
 }

delay (1000);
}

i need to add if condition as i shown in code