How can I stop buzzing after 3 sec automatically?

This is the code I am using, please help me out as this is my first arduino based project.

int x = 1; // take int value as 1

void setup() {
pinMode(A0, INPUT); //analog pins as input
pinMode(A1, INPUT);
pinMode(A2, INPUT);
pinMode(A3, INPUT);
pinMode(A4, INPUT);
pinMode(A5, INPUT);
pinMode(0, INPUT); //digital pins as input
pinMode(1, INPUT);
pinMode(12, OUTPUT); //Digital pins as output for seven seg display
pinMode(11, OUTPUT);
pinMode(10, OUTPUT);
pinMode(9, OUTPUT);
pinMode(8, OUTPUT);
pinMode(7, OUTPUT);
pinMode(6, OUTPUT);
pinMode(4, OUTPUT); // output for buzzer

// set initially display to 0
digitalWrite(12, HIGH); // seg a
digitalWrite(11, HIGH); // seg b
digitalWrite(10, HIGH); // seg c
digitalWrite(9, HIGH); //seg d
digitalWrite(8, HIGH); //seg e
digitalWrite(7, HIGH); // seg f
digitalWrite(6, LOW); //seg g

digitalWrite(4, LOW); // buzzer as off

}

void loop()
{

int a = digitalRead(A0); // reading pin values for 8 buttons
int b = digitalRead(A1);
int c = digitalRead(A2);
int d = digitalRead(A3);
int e = digitalRead(A4);
int f = digitalRead(A5);
int g = digitalRead(0);
int h = digitalRead(1);

if (a == LOW) //if 1 player press button
{ if (x == 1) // check if x is 1 if yes then execute the code
{
digitalWrite(4, HIGH); // buzzer on
digitalWrite(11, HIGH); // pirnt 1
digitalWrite(10, HIGH);
digitalWrite(9, LOW);
digitalWrite(8, LOW);
digitalWrite(7, LOW);
digitalWrite(6, LOW);
digitalWrite(12, LOW);
x++; //increment x
}
}
else if (b == LOW) //if player 2 press button
{
if (x == 1) // check if x is 1 if yes then execute the code
{
digitalWrite(4, HIGH); // buzzer on
digitalWrite(11, HIGH); // pirnt 2
digitalWrite(12, HIGH);
digitalWrite(9, HIGH);
digitalWrite(8, HIGH);
digitalWrite(7, LOW);
digitalWrite(6, HIGH);
digitalWrite(10, LOW);
x++;
}
}
else if (c == LOW) //if player 3 press button
{
if (x == 1) // check if x is 1 if yes then execute the code
{
digitalWrite(4, HIGH); // buzzer on
digitalWrite(11, HIGH); // pirnt 3
digitalWrite(12, HIGH);
digitalWrite(10, HIGH);
digitalWrite(9, HIGH);
digitalWrite(6, HIGH);
digitalWrite(7, LOW);
digitalWrite(8, LOW);
x++;
}
}
else if (d == LOW) //if player 4 press button
{ if (x == 1) // check if x is 1 if yes then execute the code
{
digitalWrite(4, HIGH); // buzzer on
digitalWrite(11, HIGH); // pirnt 4
digitalWrite(10, HIGH);
digitalWrite(7, HIGH);
digitalWrite(6, HIGH);
digitalWrite(8, LOW);
digitalWrite(9, LOW);
digitalWrite(12, LOW);
x++;
}
}
else if (e == LOW) //if player 5 press button
{
if (x == 1) // check if x is 1 if yes then execute the code
{
digitalWrite(4, HIGH); // buzzer on
digitalWrite(10, HIGH); // pirnt 5
digitalWrite(12, HIGH);
digitalWrite(9, HIGH);
digitalWrite(7, HIGH);
digitalWrite(6, HIGH);
digitalWrite(11, LOW);
digitalWrite(8, LOW);
x++;
}
}
else if (f == LOW) //if player 6 press button
{ if (x == 1) // check if x is 1 if yes then execute the code
{
digitalWrite(4, HIGH); // buzzer on
digitalWrite(10, HIGH); // pirnt 6
digitalWrite(12, HIGH);
digitalWrite(9, HIGH);
digitalWrite(8, HIGH);
digitalWrite(7, HIGH);
digitalWrite(6, HIGH);
digitalWrite(11, LOW);
x++;
}
}
else if (g == LOW) //if player 7 press button
{ if (x == 1) // check if x is 1 if yes then execute the code
{
digitalWrite(4, HIGH); // buzzer on
digitalWrite(10, HIGH); // pirnt 7
digitalWrite(12, HIGH);
digitalWrite(9, LOW);
digitalWrite(8, LOW);
digitalWrite(7, LOW);
digitalWrite(6, LOW);
digitalWrite(11, HIGH);
x++;
}
}

else if (h == LOW) //if player 8 press button
{ if (x == 1) // check if x is 1 if yes then execute the code
{
digitalWrite(4, HIGH); // buzzer on
digitalWrite(10, HIGH); // pirnt 8
digitalWrite(12, HIGH);
digitalWrite(9, HIGH);
digitalWrite(8, HIGH);
digitalWrite(7, HIGH);
digitalWrite(6, HIGH);
digitalWrite(11, HIGH);
x++;
}
}

}

How can I stop buzzing after 3 sec automatically?

You need to clarify this. Three seconds after the Arduino starts? Three seconds after the buzzer is turned on?

Three seconds after the buzzer is turned on

Tausif25:
Three seconds after the buzzer is turned on

What would YOU need to know to do that? What does the Arduino know?

When the buzzer was turned on?
What time it is now?
How long the buzzer has been on?

Its a finger press quiz buzzer project. When I press a switch as a player the buzzer starts buzzing and its not being off unless I press the reset button on Arduino Uno.

Tausif25:
Its a finger press quiz buzzer project. When I press a switch as a player the buzzer starts buzzing and its not being off unless I press the reset button on Arduino Uno.

That does not answer any of my questions.

You need to record when you turned the noise-maker pin on. You don't do that.

Periodically, usually on every pass through loop(), you see if the pin is on and, if it is, how long it has been on. If it is on, and has been on for long enough, turn it off and reset the time.

Use millis() to get the time that the pin was turned on. Use millis() to get the current time.

The demo Several Things at a Time illustrates the use of millis() to manage timing without blocking. It may help with understanding the technique.

Have a look at Using millis() for timing. A beginners guide if you need more explanation.

And when you have repetitive code like this

digitalWrite(12, HIGH);  // seg a
  digitalWrite(11, HIGH);  // seg b
  digitalWrite(10, HIGH);  // seg c
  digitalWrite(9, HIGH);   //seg d
  digitalWrite(8, HIGH);   //seg e
  digitalWrite(7, HIGH);   // seg f
  digitalWrite(6, LOW);    //seg g

it is time to learn about arrays.

...R