It gives some glitching on 7 segment display It gives the right value on the monitor but it doesnt display the value on my display.

int pinNumb[7] = {2, 3, 4, 5, 6, 7, 8};
int num_array[11][7] = {
  { 1, 1, 1, 1, 1, 0, 1 }, // 0
  { 0, 1, 1, 0, 0, 0, 0 }, // 1
  { 1, 1, 0, 1, 1, 1, 0 }, // 2
  { 1, 1, 1, 1, 0, 1, 0 }, // 3
  { 0, 1, 1, 0, 0, 1, 1 }, // 4
  { 1, 0, 1, 1, 0, 1, 1 }, // 5
  { 1, 0, 1, 1, 1, 1, 1 }, // 6
  { 1, 1, 1, 0, 0, 0, 0 }, // 7
  { 1, 1, 1, 1, 1, 1, 1 }, // 8
  { 1, 1, 1, 0, 0, 1, 1 }, // 9
  { 0, 0, 0, 0, 0, 0, 0 }  //nothing
};

int pin = 2;
int button = 12;
int buttonVal;
int randVal;
bool pressVal;
void setup() {
  Serial.begin(9600);

  for (int i = 0; i &lt; 7 ; i++)
  {
    pinMode(pinNumb[i], OUTPUT);
  }
  pressVal = false;
  pinMode(button, INPUT);
}

void loop() {
  buttonVal = digitalRead(button);
  if (buttonVal == 0) 
  {
    //zero();
    turnOff();
    pressVal = false;
  }
  else
  {
    //zero();
    if (pressVal == false)
    {
      randVal = rand() % 10;
      pressVal = true;
      delay(100);
    }
    Serial.println(randVal);
    if (randVal == 0)
    {
      zero();

    }
    else if (randVal == 1)
    {
      one();

    }
    else if (randVal == 2)
    {
      two();

    }
    else if (randVal == 3)
    {
      three();

    }
    else if (randVal == 4)
    {
      four();

    }
    else if (randVal == 5)
    {
      five();

    }
    else if (randVal == 6)
    {
      six();

    }
    else if (randVal == 7)
    {
      seven();

    }
    else if (randVal == 8)
    {
      eight();

    }
    else
    {
      nine();

    }
  }
}

void zero()
{
  for(int i = 0; i &lt; 7 ; i++)
  {
    digitalWrite(pinNumb[i],LOW);  
  }
  for (int j = 0; j &lt; 7; j++) {
    digitalWrite(pin, num_array[0][j]);
    pin++;
  }
}

void one()
{
  for(int i = 0; i &lt; 7 ; i++)
  {
    digitalWrite(pinNumb[i],LOW);  
  }
  for (int j = 0; j &lt; 7; j++) {
    digitalWrite(pin, num_array[1][j]);
    pin++;
  }
}

void two()
{
  for(int i = 0; i &lt; 7 ; i++)
  {
    digitalWrite(pinNumb[i],LOW);  
  }
  for (int j = 0; j &lt; 7; j++) {
    digitalWrite(pin, num_array[2][j]);
    pin++;
  }
}
void three()
{
  for(int i = 0; i &lt; 7 ; i++)
  {
    digitalWrite(pinNumb[i],LOW);  
  }
  for (int j = 0; j &lt; 7; j++) {
    digitalWrite(pin, num_array[3][j]);
    pin++;
  }
}
void four()
{
  for(int i = 0; i &lt; 7 ; i++)
  {
    digitalWrite(pinNumb[i],LOW);  
  }
  for (int j = 0; j &lt; 7; j++) {
    digitalWrite(pin, num_array[4][j]);
    pin++;
  }
}
void five()
{
  for(int i = 0; i &lt; 7 ; i++)
  {
    digitalWrite(pinNumb[i],LOW);  
  }
  for (int j = 0; j &lt; 7; j++) {
    digitalWrite(pin, num_array[5][j]);
    pin++;
  }
}
void six()
{
  for(int i = 0; i &lt; 7 ; i++)
  {
    digitalWrite(pinNumb[i],LOW);  
  }
  for (int j = 0; j &lt; 7; j++) {
    digitalWrite(pin, num_array[6][j]);
    pin++;
  }
}
void seven()
{
  for(int i = 0; i &lt; 7 ; i++)
  {
    digitalWrite(pinNumb[i],LOW);  
  }
  for (int j = 0; j &lt; 7; j++) {
    digitalWrite(pin, num_array[7][j]);
    pin++;
  }
}
void eight()
{
  for(int i = 0; i &lt; 7 ; i++)
  {
    digitalWrite(pinNumb[i],LOW);  
  }
  for (int j = 0; j &lt; 7; j++) {
    digitalWrite(pin, num_array[8][j]);
    pin++;
  }
}
void nine()
{
  for(int i = 0; i &lt; 7 ; i++)
  {
    digitalWrite(pinNumb[i],LOW);  
  }
  for (int j = 0; j &lt; 7; j++) {
    digitalWrite(pin, num_array[9][j]);
    pin++;
  }
}
void turnOff()
{
  for(int i = 0; i &lt; 7 ; i++)
  {
    digitalWrite(pinNumb[i],LOW);  
  }

}
These can all be byte instead of int to save on memory:

int pinNumb[7] = {2, 3, 4, 5, 6, 7, 8};
int num_array[11][7] = {
  { 1, 1, 1, 1, 1, 0, 1 }, // 0
  { 0, 1, 1, 0, 0, 0, 0 }, // 1
  { 1, 1, 0, 1, 1, 1, 0 }, // 2
  { 1, 1, 1, 1, 0, 1, 0 }, // 3
  { 0, 1, 1, 0, 0, 1, 1 }, // 4
  { 1, 0, 1, 1, 0, 1, 1 }, // 5
  { 1, 0, 1, 1, 1, 1, 1 }, // 6
  { 1, 1, 1, 0, 0, 0, 0 }, // 7
  { 1, 1, 1, 1, 1, 1, 1 }, // 8
  { 1, 1, 1, 0, 0, 1, 1 }, // 9
  { 0, 0, 0, 0, 0, 0, 0 }  //nothing
};

int pin = 2;
int button = 12;
int buttonVal;
int randVal;


In addition, the array can be reduced to 11 bytes:

0bFD, // 0
0bC0, // 1
0bDE, // 2 
etc.


Then your functions can do direct port manipulation to send bits 0-5 to the Port for D2 to D7, and bit to D8.

As written, these functions probably need some hold time so they don't just flash the LED and disappear:

void one()
{
  for(int i = 0; i &lt; 7 ; i++)
  {
    digitalWrite(pinNumb[i],LOW);  
  }
  for (int j = 0; j &lt; 7; j++) {
    digitalWrite(pin, num_array[1][j]);
    pin++;
  }
}