8 bit binary led counter

i made a binary led counter but i want to control it with switch…once i toggle the switch the counting stops and resume when i switch it off…please help me…

void setup()
{
pinMode(2,OUTPUT);
pinMode(3,OUTPUT);
pinMode(4,OUTPUT);
pinMode(5,OUTPUT);
pinMode(6,OUTPUT);
pinMode(7,OUTPUT);
pinMode(8,OUTPUT);
pinMode(9,OUTPUT);
}

void loop()
{

for(byte i=0;i<255;i++)
{ byte a=i%2;
byte b=i/2 %2;
byte c=i/4 %2;
byte d=i/8 %2;
byte e=i/16 %2;
byte f=i/32 %2;
byte g=i/64 %2;
byte h=i/128 %2;

digitalWrite(2,a);
digitalWrite(3,b);
digitalWrite(4,c);
digitalWrite(5,d);
digitalWrite(6,e);
digitalWrite(7,f);
digitalWrite(8,g);
digitalWrite(9,h);

delay(200);
}
}

In the future, please obey forum rules and post your code between code tags.

Untested and I just modified the code you posted, but:

void setup()  
 {  
  pinMode(2,OUTPUT);   
  pinMode(3,OUTPUT);  
  pinMode(4,OUTPUT);  
  pinMode(5,OUTPUT);
  pinMode(6,OUTPUT);
  pinMode(7,OUTPUT);
  pinMode(8,OUTPUT);
  pinMode(9,OUTPUT);

  pinMode(10, INPUT);
 }  
 
 void loop()  
 {

   for(byte i=0;i<255;i++) 
   { 

      if(digitalRead(10))
      {

   byte a=i%2;      
   byte b=i/2 %2;     
   byte c=i/4 %2;        
   byte d=i/8 %2;
 byte e=i/16 %2;
byte f=i/32 %2;
byte g=i/64 %2;
byte h=i/128 %2;
  
digitalWrite(2,a); 
digitalWrite(3,b); 
digitalWrite(4,c); 
digitalWrite(5,d); 
digitalWrite(6,e); 
digitalWrite(7,f); 
digitalWrite(8,g);
digitalWrite(9,h);
   
   delay(200);     
  }
  }
}

Button between digital pin 10 and ground with a pullup resistor to Vcc.

Oracle: In the future, please obey forum rules and post your code between code tags.

Even better, do it now.

Go and read the instructions, then go back and modify your post (use the "More --> Modify" option to the bottom right of the post) to mark up the code as such so we can examine it conveniently and accurately.