Variables adding up when not needed to

Hi, I'm working on a school project and my code seems to be buggy. variable values are not supposed to be adding up when in the main menu or inside a category. But when for example, I'm in menu 3 and vote for CD1 there, then that particular variable should get added up. But it seems that CD3 in every menu get added up when choosing the sub-menu or voting. All CD3 get added up.
If anyone knows how to fix this, pls help.

#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27, 16, 2);


#define S1 7
#define S2 6
#define S3 5
#define S4 4
#define S5 3
#define S6 2
int vote1 = 0;
int vote2 = 0;
int vote3 = 0;
int vote4 = 0;
int vote5 = 0;
int vote6 = 0;
int vote7 = 0;
int vote8 = 0;
int vote9 = 0;
int vote10 = 0;
int vote11 = 0;
int vote12 = 0;
int vote13 = 0;
int vote14 = 0;
int vote15 = 0;
int vote16 = 0;
int stat = 0;
void setup()
{
  Serial.begin(9600);
  lcd.begin();
  lcd.backlight();
  pinMode(S1, INPUT);
  pinMode(S2, INPUT);
  pinMode(S3, INPUT);
  pinMode(S4, INPUT);
  pinMode(S5, INPUT);
  pinMode(S6, INPUT);

  digitalWrite(S1, HIGH);
  digitalWrite(S2, HIGH);
  digitalWrite(S3, HIGH);
  digitalWrite(S4, HIGH);
  digitalWrite(S5, HIGH);
  digitalWrite(S6, HIGH);
}
void loop()
{
 /* Serial.print("1:");
    Serial.println(vote13);
    Serial.print("2:");
    Serial.println(vote14);
    Serial.print("3:");
    Serial.println(vote15);
    Serial.print("4:");
    Serial.println(vote16);
    delay(100);*/
  if (stat == 0) {
    lcd.setCursor(0, 0);
    lcd.print("VCE");
    lcd.setCursor(1, 1);

    lcd.setCursor(4, 0);
    lcd.print("CCA");
    lcd.setCursor(5, 1);

    lcd.setCursor(8, 0);
    lcd.print("DIS");
    lcd.setCursor(9, 1);

    lcd.setCursor(12, 0);
    lcd.print("SPT");
    lcd.setCursor(13, 1);
  }
  if (digitalRead(S6) == 0 && stat >= 1) {
    lcd.clear();
    stat = 0;
  }
  if (digitalRead(S1) == 0 && stat == 0) {
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("Pick");
    lcd.setCursor(0, 1);
    lcd.print("Candidate");
    stat++;
    delay(1500);
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("CD1");
    lcd.setCursor(6, 0);
    lcd.print("CD2");
    lcd.setCursor(13, 0);
    lcd.print("CD3");


  }
  if (digitalRead(S2) == 0 && stat == 0) {
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("Pick");
    lcd.setCursor(0, 1);
    lcd.print("Candidate");
    stat = 2;
    delay(1500);
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("CD1");
    lcd.setCursor(6, 0);
    lcd.print("CD2");

  }
  if (digitalRead(S3) == 0 && stat == 0) {
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("Pick");
    lcd.setCursor(0, 1);
    lcd.print("Candidate");
    stat=3;
    delay(1500);
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("CD1");
    lcd.setCursor(6, 0);
    lcd.print("CD2");
    lcd.setCursor(13, 0);
    lcd.print("CD3");

  }
  if (digitalRead(S4) == 0 && stat == 0) {
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("Pick");
    lcd.setCursor(0, 1);
    lcd.print("Candidate");
    stat = 4;
    delay(1500);
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("CD1");
    lcd.setCursor(9, 0);
    lcd.print("CD2");

  }
  if (stat == 1 ); {
    if (digitalRead(S1) == 0)
      vote1++;



    delay(10);
    while (digitalRead(S1) == 0);
    if (digitalRead(S2) == 0)
      vote2++;


    delay(10);


    while (digitalRead(S2) == 0);
    if (digitalRead(S3) == 0)
      vote3++;


    delay(10);


    while (digitalRead(S3) == 0);
    if (digitalRead(S4) == 0)
      



    delay(10);
  
  else if (stat != 1 && stat!=2 && stat!=3 && stat!=4 ){
    
  }}
  if (stat == 2 ); {
    if (digitalRead(S1) == 0)
      vote5++;



    delay(10);
    while (digitalRead(S1) == 0);
    if (digitalRead(S2) == 0)
      vote6++;


    delay(10);


    while (digitalRead(S2) == 0);
    if (digitalRead(S3) == 0)
    
    delay(10);


    while (digitalRead(S3) == 0);
    if (digitalRead(S4) == 0)
     



    delay(10);

  
     else if (stat != 1 && stat!=2 && stat!=3 && stat!=4 ){
    
  }}
  if (stat == 3 ); {
    if (digitalRead(S1) == 0)
      vote9++;



    delay(10);
    while (digitalRead(S1) == 0);
    if (digitalRead(S2) == 0)
      vote10++;


    delay(10);


    while (digitalRead(S2) == 0);
    if (digitalRead(S3) == 0)
      


    delay(10);


    while (digitalRead(S3) == 0);
    if (digitalRead(S4) == 0)
      



    delay(10);
  
     else if (stat != 1 && stat!=2 && stat!=3 && stat!=4 ){
    
  }}
  if (stat == 4 ); {
    if (digitalRead(S1) == 0)
      vote13++;



    delay(10);
    while (digitalRead(S1) == 0);
    if (digitalRead(S2) == 0)
      vote14++;


    delay(10);


    while (digitalRead(S2) == 0);
    if (digitalRead(S3) == 0)
      


    delay(10);


    while (digitalRead(S3) == 0);
    if (digitalRead(S4) == 0)
      



    delay(10);

  
    else if (stat != 1 && stat!=2 && stat!=3 && stat!=4 ){
    
  }}
  while (digitalRead(S4) == 0);
  if (digitalRead(S5) == 0 && stat == 1)
  {
    int vote = vote1 + vote2 + vote3 + vote4;
    if (vote)
    {
      if ((vote1 > vote2 && vote1 > vote3 && vote1 > vote4))
      {
        lcd.clear();
        lcd.print("VICE:CD1");
        lcd.setCursor(0, 1);
        lcd.print("is Winner");
        lcd.setCursor(10, 1);
        lcd.print(vote1);
        delay(3000);
        lcd.clear();
        stat = 0;
      }
      else if ((vote2 > vote1 && vote2 > vote3 && vote2 > vote4))
      {
        lcd.clear();
        lcd.print("VICE:CD2");
        lcd.setCursor(0, 1);
        lcd.print("is Winner");
        lcd.setCursor(10, 1);
        lcd.print(vote2);
        delay(3000);
        lcd.clear();
        stat = 0;
      }
      else if ((vote3 > vote1 && vote3 > vote2 && vote3 > vote4))
      {
        lcd.clear();
        lcd.print("VICE:CD3");
        lcd.setCursor(0, 1);
        lcd.print("is Winner");
        lcd.setCursor(10, 1);
        lcd.print(vote3);
        delay(3000);
        lcd.clear();
        stat = 0;
      }
      else if (vote4 > vote1 && vote4 > vote2 && vote4 > vote3)
      {
        lcd.setCursor(0, 0);
        lcd.clear();
        lcd.print("Error B4 E1");
        lcd.print(vote3);
        delay(3000);
        lcd.clear();
        stat = 0;
      }


      else if (vote1 == 0 && vote2 == 0 && vote3 == 0 && vote4 == 0) {
        {
          lcd.clear();
          lcd.print(" Tie Up Or ");
          lcd.setCursor(0, 1);
          lcd.print(" No Result ");
          delay(3000);
          lcd.clear();
          stat = 0;
        }
      }
        lcd.print("System reset triggered");
      Serial.println("category 1");
      Serial.print("CD1  ");
      Serial.println(vote1);
      Serial.print("CD2  ");
      Serial.println(vote2);
      Serial.print("CD3  ");
      Serial.println(vote3);
      Serial.println("category 2");
      Serial.print("CD1  ");
      Serial.println(vote5);
      Serial.print("CD2  ");
      Serial.println(vote6);
      Serial.println("category 3");
      Serial.print("CD1  ");
      Serial.println(vote9);
      Serial.print("CD2  ");
      Serial.println(vote10);
      Serial.print("CD3");
      Serial.println(vote11);
      Serial.println("category 4");
      Serial.print("CD1");
      Serial.println(vote13);
      Serial.print("CD2  ");
      Serial.println(vote14);
      delay(750);
    }
    else
    {
      lcd.clear();
      lcd.print("No Voting....");
      stat = 0;
      delay(3000);
      lcd.clear();
        
    }
    vote1 = 0; vote2 = 0; vote3 = 0; vote4 = 0, vote = 0;
    lcd.clear();
  }
    while (digitalRead(S4) == 0);
  if (digitalRead(S5) == 0 && stat == 2)
  {
    int voterr = vote5 + vote6 + vote7 + vote8;
    if (voterr)
    {
      if ((vote5 > vote6 && vote5 > vote7 && vote5 > vote8))
      {
        lcd.clear();
        lcd.print("CCA: CD1");
        lcd.setCursor(0, 1);
        lcd.print("is Winner");
        lcd.setCursor(10, 1);
        lcd.print(vote5);
        delay(3000);
        lcd.clear();
        stat = 0;
      }
      else if ((vote6 > vote5 && vote6 > vote7 && vote6 > vote8))
      {
        lcd.clear();
        lcd.print("CCA: CD2");
        lcd.setCursor(0, 1);
        lcd.print("is Winner");
        lcd.setCursor(10, 1);
        lcd.print(vote6);
        delay(3000);
        lcd.clear();
        stat = 0;
      }
      else if ((vote7 > vote5 && vote7 > vote6 && vote7 > vote8))
      {
        lcd.clear();
        lcd.print("DISC:CD3");
        lcd.setCursor(0, 1);
        lcd.print("is Winner");
        lcd.setCursor(10, 1);
        lcd.print(vote11);
        delay(3000);
        lcd.clear();
        stat = 0;
      }
      else if (vote8 > vote5 && vote8 > vote6 && vote8 > vote7)
      {
        lcd.setCursor(0, 0);
        lcd.clear();
        lcd.print("Error B4 E21");
        lcd.setCursor(0,1);
        lcd.print(vote12);
        delay(3000);
        lcd.clear();
        stat = 0;
      }


      else if (vote5 == 0 && vote6 == 0 && vote7 == 0 && vote8 == 0) {
        {
          lcd.clear();
          lcd.print(" Tie Up Or ");
          lcd.setCursor(0, 1);
          lcd.print(" No Result ");
          delay(3000);
          lcd.clear();
          stat = 0;
        }
      }
           lcd.print("System reset triggered");
      Serial.println("category 1");
      Serial.print("CD1  ");
      Serial.println(vote1);
      Serial.print("CD2  ");
      Serial.println(vote2);
      Serial.print("CD3  ");
      Serial.println(vote3);
      Serial.println("category 2");
      Serial.print("CD1  ");
      Serial.println(vote5);
      Serial.print("CD2  ");
      Serial.println(vote6);
      Serial.println("category 3");
      Serial.print("CD1  ");
      Serial.println(vote9);
      Serial.print("CD2  ");
      Serial.println(vote10);
      Serial.print("CD3");
      Serial.println(vote11);
      Serial.println("category 4");
      Serial.print("CD1");
      Serial.println(vote13);
      Serial.print("CD2  ");
      Serial.println(vote14);
      delay(750);
    }
    else
    {
      lcd.clear();
      lcd.print("No Voting....");
      stat = 0;
      delay(3000);
      lcd.clear();
    }
    vote5 = 0; vote6 = 0; vote7 = 0; vote8 = 0, voterr = 0;
    lcd.clear();
  }
   while (digitalRead(S4) == 0);
  if (digitalRead(S5) == 0 && stat == 3)
  {
    int votes = vote9 + vote10 + vote11 + vote12;
    if (votes)
    {
      if ((vote9 > vote10 && vote9 > vote11 && vote9 > vote12))
      {
        lcd.clear();
        lcd.print("DISC: CD1");
        lcd.setCursor(0, 1);
        lcd.print("is Winner");
        lcd.setCursor(10, 1);
        lcd.print(vote9);
        delay(3000);
        lcd.clear();
        stat = 0;
      }
      else if ((vote10 > vote9 && vote10 > vote11 && vote10 > vote12))
      {
        lcd.clear();
        lcd.print("DISC:CD2");
        lcd.setCursor(0, 1);
        lcd.print("is Winner");
        lcd.setCursor(10, 1);
        lcd.print(vote10);
        delay(3000);
        lcd.clear();
        stat = 0;
      }
      else if ((vote11 > vote9 && vote11 > vote10 && vote11 > vote12))
      {
        lcd.clear();
        lcd.print("DISC:CD3");
        lcd.setCursor(0, 1);
        lcd.print("is Winner");
        lcd.setCursor(10, 1);
        lcd.print(vote11);
        delay(3000);
        lcd.clear();
        stat = 0;
      }
      else if (vote12 > vote9 && vote12 > vote10 && vote12 > vote11)
      {
        lcd.setCursor(0, 0);
        lcd.clear();
        lcd.print("Error B4 E21");
        lcd.setCursor(0,1);
        lcd.print(vote12);
        delay(3000);
        lcd.clear();
        stat = 0;
      }


      else if (vote9 == 0 && vote10 == 0 && vote11 == 0 && vote12 == 0) {
        {
          lcd.clear();
          lcd.print(" Tie Up Or ");
          lcd.setCursor(0, 1);
          lcd.print(" No Result ");
          delay(3000);
          lcd.clear();
          stat = 0;
        }
      }
           lcd.print("System reset triggered");
      Serial.println("category 1");
      Serial.print("CD1  ");
      Serial.println(vote1);
      Serial.print("CD2  ");
      Serial.println(vote2);
      Serial.print("CD3  ");
      Serial.println(vote3);
      Serial.println("category 2");
      Serial.print("CD1  ");
      Serial.println(vote5);
      Serial.print("CD2  ");
      Serial.println(vote6);
      Serial.println("category 3");
      Serial.print("CD1  ");
      Serial.println(vote9);
      Serial.print("CD2  ");
      Serial.println(vote10);
      Serial.print("CD3");
      Serial.println(vote11);
      Serial.println("category 4");
      Serial.print("CD1");
      Serial.println(vote13);
      Serial.print("CD2  ");
      Serial.println(vote14);
      delay(750);
    }
    else
    {
      lcd.clear();
      lcd.print("No Voting....");
      stat = 0;
      delay(3000);
      lcd.clear();
    }
    vote9 = 0; vote10 = 0; vote11 = 0; vote12 = 0, votes = 0;
    lcd.clear();
  }
  while (digitalRead(S4) == 0);
  if (digitalRead(S5) == 0 && stat == 4)
  {
    int votess = vote13 + vote14 + vote15 + vote16;
    if (votess)
    {
      if ((vote13 > vote14 && vote13 > vote15 && vote13 > vote16))
      {
        lcd.clear();
        lcd.print("SPRT:CD1");
        lcd.setCursor(0, 1);
        lcd.print("is Winner");
        lcd.setCursor(10, 1);
        lcd.print(vote13);
        delay(3000);
        lcd.clear();
        stat = 0;
      }
      else if ((vote14 > vote13 && vote14 > vote15 && vote14 > vote16))
      {
        lcd.clear();
        lcd.print("SPRT: CD2");
        lcd.setCursor(0, 1);
        lcd.print("is Winner");
        lcd.setCursor(10, 1);
        lcd.print(vote14);
        delay(3000);
        lcd.clear();
        stat = 0;
      }
      else if ((vote15 > vote13 && vote15 > vote14 && vote15 > vote16))
      {
        lcd.clear();
        lcd.print("Error b4 e31");
        lcd.setCursor(0, 1);

        lcd.setCursor(10, 1);
        lcd.print(vote15);
        delay(3000);
        lcd.clear();
        stat = 0;
      }
      else if (vote16 > vote13 && vote16 > vote14 && vote16 > vote15)
      {
        lcd.setCursor(0, 0);
        lcd.clear();
        lcd.print("Error B4 E32");
        lcd.print(vote16);
        delay(3000);
        lcd.clear();
        stat = 0;
      }


      else if (vote13 == 0 && vote14 == 0 && vote15 == 0 && vote16 == 0) {
        {
          lcd.clear();
          lcd.print(" Tie Up Or ");
          lcd.setCursor(0, 1);
          lcd.print(" No Result ");
          delay(3000);
          lcd.clear();
        }
      }
          lcd.print("System reset triggered");
      Serial.println("category 1");
      Serial.print("CD1  ");
      Serial.println(vote1);
      Serial.print("CD2  ");
      Serial.println(vote2);
      Serial.print("CD3  ");
      Serial.println(vote3);
      Serial.println("category 2");
      Serial.print("CD1  ");
      Serial.println(vote5);
      Serial.print("CD2  ");
      Serial.println(vote6);
      Serial.println("category 3");
      Serial.print("CD1  ");
      Serial.println(vote9);
      Serial.print("CD2  ");
      Serial.println(vote10);
      Serial.print("CD3");
      Serial.println(vote11);
      Serial.println("category 4");
      Serial.print("CD1");
      Serial.println(vote13);
      Serial.print("CD2  ");
      Serial.println(vote14);
      delay(750); 
    }
    else
    {
      lcd.clear();
      lcd.print("No Voting....");
      stat = 0;
      delay(3000);
      lcd.clear();

    }
    vote13 = 0; vote14 = 0; vote15 = 0; vote16 = 0, votess = 0;
    lcd.clear();
  }

}```
     if (stat == 1 ); {
    if (digitalRead(S1) == 0)
      vote1++;

Did you deliberately end the if statement with a semicolon and if so, why ?

And that's not the only example:

Presumably there is further code to go into the 'else if' clause in this and other similar examples of this statement?

Okay some/most of the code's fundamental operations are from another contributor. I've done the good old copy paste. So are you suggesting that I should try <{}> in the second if statement which you've highlighted?

Fix the serious errors just reported to you, and retest the code. For example, remove the semicolon ";" here, and in the other places it should not be found.

if (stat == 4 ); {

Come back with revised questions.

There is also a lot of this:
while (digitalRead(S3) == 0);
This expression will wait until you press the button connected to S3. Maybe you want that behaviour...

Your code could be reduced in size tremendously if you would use functions and arrays. It would also make life easier for us (trying to catch errors) and you (correcting errors).

On your original question:
I guess you would need a 2D array to store your votes.
Like

int vote[nr_of_categories][number_of_what_really];

You now have only 1 variable vote1. So in each category you add up to this same variable.
You need a vote1 for each category. The easiest way is via above suggested 2D matrix.

I understand how the 2D matrix works. But I'm not sure how to code them. I'm still a beginner in programming. I'm okay with the size of the code as it is easier for me to understand/troubleshoot.
I'm going to try with the semicolons and the "{" .

Something like this should get you started...

Before setup:

const int nr_candidates = 3;
const int nr_vote_nr = 10;  //still do not understand what vote1 refers to in your code
int votes[nr_candidates][nr_vote_nr];

In loop():

    int candidate = 0;
    int vote_nr = 0; 
    votes[candidate][vote_nr] = 1;
    Serial.println(votes[candidate][vote_nr]);
    votes[2][3] = 2;
    Serial.println(votes[2][3]);
    delay(10000);

Maybe you mean voter1 instead of vote1?
In that case you would have nr_voters in above code...

Turns out it was actually the "{ }". I tried not ending the if statements with a semicolon and tried this

    if (digitalRead(S1) == 0){
      vote1++;
      delay(10);
} 

and it works and isn't adding up any values in the different categories.
Thank you everyone for helping me and essentially wasting you time :})
oh and also, the semicolons in the statement if(stat == 0); { }
also posed to be a problem. thanks for that too!

I'm Back :sweat_smile:
Now the variables aren't adding up properly.
for example: I press the button 1 twice and the vote value is registed as something higher (like 7).
Tried many things but nothing happened. Here's the updated code.

#include <Wire.h>
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27, 16, 2);


#define S1 7
#define S2 6
#define S3 5
#define S4 4
#define S5 3
#define S6 2
int vote1 = 0;
int vote2 = 0;
int vote3 = 0;
int vote4 = 0;
int vote5 = 0;
int vote6 = 0;
int vote7 = 0;
int vote8 = 0;
int vote9 = 0;
int vote10 = 0;
int vote11 = 0;
int vote12 = 0;
int vote13 = 0;
int vote14 = 0;
int vote15 = 0;
int vote16 = 0;
int stat = 0;
void setup()
{
  Serial.begin(9600);
  lcd.begin();
  lcd.backlight();
  pinMode(S1, INPUT);
  pinMode(S2, INPUT);
  pinMode(S3, INPUT);
  pinMode(S4, INPUT);
  pinMode(S5, INPUT);
  pinMode(S6, INPUT);

  digitalWrite(S1, HIGH);
  digitalWrite(S2, HIGH);
  digitalWrite(S3, HIGH);
  digitalWrite(S4, HIGH);
  digitalWrite(S5, HIGH);
  digitalWrite(S6, HIGH);
}
void loop()
{
 /* Serial.print("1:");
    Serial.println(vote13);
    Serial.print("2:");
    Serial.println(vote14);
    Serial.print("3:");
    Serial.println(vote15);
    Serial.print("4:");
    Serial.println(vote16);
    delay(100);*/
  if (stat == 0) {
    lcd.setCursor(0, 0);
    lcd.print("VCE");
    lcd.setCursor(1, 1);

    lcd.setCursor(4, 0);
    lcd.print("CCA");
    lcd.setCursor(5, 1);

    lcd.setCursor(8, 0);
    lcd.print("DIS");
    lcd.setCursor(9, 1);

    lcd.setCursor(12, 0);
    lcd.print("SPT");
    lcd.setCursor(13, 1);
  }
  if (digitalRead(S6) == 0 && stat >= 1) {
    lcd.clear();
    stat = 0;
  }
  if (digitalRead(S1) == 0 && stat == 0) {
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("Pick");
    lcd.setCursor(0, 1);
    lcd.print("Candidate");
    stat++;
    delay(1500);
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("CD1");
    lcd.setCursor(6, 0);
    lcd.print("CD2");
    lcd.setCursor(13, 0);
    lcd.print("CD3");


  }
  if (digitalRead(S2) == 0 && stat == 0) {
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("Pick");
    lcd.setCursor(0, 1);
    lcd.print("Candidate");
    stat = 2;
    delay(1500);
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("CD1");
    lcd.setCursor(6, 0);
    lcd.print("CD2");

  }
  if (digitalRead(S3) == 0 && stat == 0) {
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("Pick");
    lcd.setCursor(0, 1);
    lcd.print("Candidate");
    stat=3;
    delay(1500);
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("CD1");
    lcd.setCursor(6, 0);
    lcd.print("CD2");
    lcd.setCursor(13, 0);
    lcd.print("CD3");

  }
  if (digitalRead(S4) == 0 && stat == 0) {
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("Pick");
    lcd.setCursor(0, 1);
    lcd.print("Candidate");
    stat = 4;
    delay(1500);
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("CD1");
    lcd.setCursor(9, 0);
    lcd.print("CD2");

  }
  if (stat == 1 ) {
    if (digitalRead(S1) == 0){
      vote1++;
     
     



    delay(10);}
    while (digitalRead(S1) == 0);
    if (digitalRead(S2) == 0){
      vote2++;


    delay(10);}


    while (digitalRead(S2) == 0);
    if (digitalRead(S3) == 0){
      vote3++;


    delay(10);}


    while (digitalRead(S3) == 0);
    if (digitalRead(S4) == 0){
      



    delay(10);}
  
  else if (stat != 1 && stat!=2 && stat!=3 && stat!=4 ){
    
  }}
  if (stat == 2 ) {
    if (digitalRead(S1) == 0)
      vote5++;



    delay(10);
    while (digitalRead(S1) == 0);
    if (digitalRead(S2) == 0)
      vote6++;


    delay(10);


    while (digitalRead(S2) == 0);
    if (digitalRead(S3) == 0)
    
    delay(10);


    while (digitalRead(S3) == 0);
    if (digitalRead(S4) == 0)
     



    delay(10);

  
     else if (stat != 1 && stat!=2 && stat!=3 && stat!=4 ){
    
  }}
  if (stat == 3 ) {
    if (digitalRead(S1) == 0){
      vote9++;



    delay(10);}
    while (digitalRead(S1) == 0);
    if (digitalRead(S2) == 0)
      vote10++;


    delay(10);


    while (digitalRead(S2) == 0);
    if (digitalRead(S3) == 0)
      


    delay(10);


    while (digitalRead(S3) == 0);
    if (digitalRead(S4) == 0)
      



    delay(10);
  
     else if (stat != 1 && stat!=2 && stat!=3 && stat!=4 ){
    
  }}
  if (stat == 4 ) {
    if (digitalRead(S1) == 0){
      vote13++;



    delay(10);}
    while (digitalRead(S1) == 0);
    if (digitalRead(S2) == 0){
      vote14++;


    delay(10);
    }

    while (digitalRead(S2) == 0);
    if (digitalRead(S3) == 0){
      


    delay(10);}


    while (digitalRead(S3) == 0);
    if (digitalRead(S4) == 0){
      



    delay(10);}

  
    else if (stat != 1 && stat!=2 && stat!=3 && stat!=4 ){
    
  }}
  while (digitalRead(S4) == 0);
  if (digitalRead(S5) == 0 && stat == 1)
  {
    int vote = vote1 + vote2 + vote3 + vote4;
    if (vote)
    {
      if ((vote1 > vote2 && vote1 > vote3 && vote1 > vote4))
      {
        lcd.clear();
        lcd.print("VICE:CD1");
        lcd.setCursor(0, 1);
        lcd.print("is Winner");
        lcd.setCursor(10, 1);
        lcd.print(vote1);
        delay(3000);
        lcd.clear();
        stat = 0;
      }
      else if ((vote2 > vote1 && vote2 > vote3 && vote2 > vote4))
      {
        lcd.clear();
        lcd.print("VICE:CD2");
        lcd.setCursor(0, 1);
        lcd.print("is Winner");
        lcd.setCursor(10, 1);
        lcd.print(vote2);
        delay(3000);
        lcd.clear();
        stat = 0;
      }
      else if ((vote3 > vote1 && vote3 > vote2 && vote3 > vote4))
      {
        lcd.clear();
        lcd.print("VICE:CD3");
        lcd.setCursor(0, 1);
        lcd.print("is Winner");
        lcd.setCursor(10, 1);
        lcd.print(vote3);
        delay(3000);
        lcd.clear();
        stat = 0;
      }
      else if (vote4 > vote1 && vote4 > vote2 && vote4 > vote3)
      {
        lcd.setCursor(0, 0);
        lcd.clear();
        lcd.print("Error B4 E1");
        lcd.print(vote3);
        delay(3000);
        lcd.clear();
        stat = 0;
      }


      else if (vote1 == 0 && vote2 == 0 && vote3 == 0 && vote4 == 0) {
        {
          lcd.clear();
          lcd.print(" Tie Up Or ");
          lcd.setCursor(0, 1);
          lcd.print(" No Result ");
          delay(3000);
          lcd.clear();
          stat = 0;
        }
      }
        lcd.print("System reset triggered");
      Serial.println("category 1");
      Serial.print("CD1  ");
      Serial.println(vote1);
      Serial.print("CD2  ");
      Serial.println(vote2);
      Serial.print("CD3  ");
      Serial.println(vote3);
      Serial.println("category 2");
      Serial.print("CD1  ");
      Serial.println(vote5);
      Serial.print("CD2  ");
      Serial.println(vote6);
      Serial.println("category 3");
      Serial.print("CD1  ");
      Serial.println(vote9);
      Serial.print("CD2  ");
      Serial.println(vote10);
      Serial.print("CD3");
      Serial.println(vote11);
      Serial.println("category 4");
      Serial.print("CD1 ");
      Serial.println(vote13);
      Serial.print("CD2  ");
      Serial.println(vote14);
      delay(750);
    }
    else
    {
      lcd.clear();
      lcd.print("No Voting....");
      stat = 0;
      delay(3000);
      lcd.clear();
        
    }
    vote1 = 0; vote2 = 0; vote3 = 0; vote4 = 0, vote = 0;
    lcd.clear();
  }
    while (digitalRead(S4) == 0);
  if (digitalRead(S5) == 0 && stat == 2)
  {
    int voterr = vote5 + vote6 + vote7 + vote8;
    if (voterr)
    {
      if ((vote5 > vote6 && vote5 > vote7 && vote5 > vote8))
      {
        lcd.clear();
        lcd.print("CCA: CD1");
        lcd.setCursor(0, 1);
        lcd.print("is Winner");
        lcd.setCursor(10, 1);
        lcd.print(vote5);
        delay(3000);
        lcd.clear();
        stat = 0;
      }
      else if ((vote6 > vote5 && vote6 > vote7 && vote6 > vote8))
      {
        lcd.clear();
        lcd.print("CCA: CD2");
        lcd.setCursor(0, 1);
        lcd.print("is Winner");
        lcd.setCursor(10, 1);
        lcd.print(vote6);
        delay(3000);
        lcd.clear();
        stat = 0;
      }
      else if ((vote7 > vote5 && vote7 > vote6 && vote7 > vote8))
      {
        lcd.clear();
        lcd.print("DISC:eror");
        lcd.setCursor(0, 1);
        lcd.print("is Winner");
        lcd.setCursor(10, 1);
        lcd.print(vote11);
        delay(3000);
        lcd.clear();
        stat = 0;
      }
      else if (vote8 > vote5 && vote8 > vote6 && vote8 > vote7)
      {
        lcd.setCursor(0, 0);
        lcd.clear();
        lcd.print("Error B4 E21");
        lcd.setCursor(0,1);
        lcd.print(vote12);
        delay(3000);
        lcd.clear();
        stat = 0;
      }


      else if (vote5 == 0 && vote6 == 0 && vote7 == 0 && vote8 == 0) {
        {
          lcd.clear();
          lcd.print(" Tie Up Or ");
          lcd.setCursor(0, 1);
          lcd.print(" No Result ");
          delay(3000);
          lcd.clear();
          stat = 0;
        }
      }
         lcd.print("System reset triggered");
      Serial.println("category 1");
      Serial.print("CD1  ");
      Serial.println(vote1);
      Serial.print("CD2  ");
      Serial.println(vote2);
      Serial.print("CD3  ");
      Serial.println(vote3);
      Serial.println("category 2");
      Serial.print("CD1  ");
      Serial.println(vote5);
      Serial.print("CD2  ");
      Serial.println(vote6);
      Serial.println("category 3");
      Serial.print("CD1  ");
      Serial.println(vote9);
      Serial.print("CD2  ");
      Serial.println(vote10);
      Serial.print("CD3");
      Serial.println(vote11);
      Serial.println("category 4");
      Serial.print("CD1 ");
      Serial.println(vote13);
      Serial.print("CD2  ");
      Serial.println(vote14);
      delay(750);
    }
    else
    {
      lcd.clear();
      lcd.print("No Voting....");
      stat = 0;
      delay(3000);
      lcd.clear();
    }
    vote5 = 0; vote6 = 0; vote7 = 0; vote8 = 0, voterr = 0;
    lcd.clear();
  }
   while (digitalRead(S4) == 0);
  if (digitalRead(S5) == 0 && stat == 3)
  {
    int votes = vote9 + vote10 + vote11 + vote12;
    if (votes)
    {
      if ((vote9 > vote10 && vote9 > vote11 && vote9 > vote12))
      {
        lcd.clear();
        lcd.print("DISC: Cd1");
        lcd.setCursor(0, 1);
        lcd.print("is Winner");
        lcd.setCursor(10, 1);
        lcd.print(vote9);
        delay(3000);
        lcd.clear();
        stat = 0;
      }
      else if ((vote10 > vote9 && vote10 > vote11 && vote10 > vote12))
      {
        lcd.clear();
        lcd.print("DISC:CD2");
        lcd.setCursor(0, 1);
        lcd.print("is Winner");
        lcd.setCursor(10, 1);
        lcd.print(vote10);
        delay(3000);
        lcd.clear();
        stat = 0;
      }
      else if ((vote11 > vote9 && vote11 > vote10 && vote11 > vote12))
      {
        lcd.clear();
        lcd.print("DISC:CD3");
        lcd.setCursor(0, 1);
        lcd.print("is Winner");
        lcd.setCursor(10, 1);
        lcd.print(vote11);
        delay(3000);
        lcd.clear();
        stat = 0;
      }
      else if (vote12 > vote9 && vote12 > vote10 && vote12 > vote11)
      {
        lcd.setCursor(0, 0);
        lcd.clear();
        lcd.print("Error B4 E21");
        lcd.setCursor(0,1);
        lcd.print(vote12);
        delay(3000);
        lcd.clear();
        stat = 0;
      }


      else if (vote9 == 0 && vote10 == 0 && vote11 == 0 && vote12 == 0) {
        {
          lcd.clear();
          lcd.print(" Tie Up Or ");
          lcd.setCursor(0, 1);
          lcd.print(" No Result ");
          delay(3000);
          lcd.clear();
          stat = 0;
        }
      }
         lcd.print("System reset triggered");
      Serial.println("category 1");
      Serial.print("CD1  ");
      Serial.println(vote1);
      Serial.print("CD2  ");
      Serial.println(vote2);
      Serial.print("CD3  ");
      Serial.println(vote3);
      Serial.println("category 2");
      Serial.print("CD1  ");
      Serial.println(vote5);
      Serial.print("CD2  ");
      Serial.println(vote6);
      Serial.println("category 3");
      Serial.print("CD1  ");
      Serial.println(vote9);
      Serial.print("CD2  ");
      Serial.println(vote10);
      Serial.print("CD3");
      Serial.println(vote11);
      Serial.println("category 4");
      Serial.print("CD1 ");
      Serial.println(vote13);
      Serial.print("CD2  ");
      Serial.println(vote14);
      delay(750);
    }
    else
    {
      lcd.clear();
      lcd.print("No Voting....");
      stat = 0;
      delay(3000);
      lcd.clear();
    }
    vote9 = 0; vote10 = 0; vote11 = 0; vote12 = 0, votes = 0;
    lcd.clear();
  }
  while (digitalRead(S4) == 0);
  if (digitalRead(S5) == 0 && stat == 4)
  {
    int votess = vote13 + vote14 + vote15 + vote16;
    if (votess)
    {
      if ((vote13 > vote14 && vote13 > vote15 && vote13 > vote16))
      {
        lcd.clear();
        lcd.print("SPRT:CD1");
        lcd.setCursor(0, 1);
        lcd.print("is Winner");
        lcd.setCursor(10, 1);
        lcd.print(vote13);
        delay(3000);
        lcd.clear();
        stat = 0;
      }
      else if ((vote14 > vote13 && vote14 > vote15 && vote14 > vote16))
      {
        lcd.clear();
        lcd.print("SPRT: CD2");
        lcd.setCursor(0, 1);
        lcd.print("is Winner");
        lcd.setCursor(10, 1);
        lcd.print(vote14);
        delay(3000);
        lcd.clear();
        stat = 0;
      }
      else if ((vote15 > vote13 && vote15 > vote14 && vote15 > vote16))
      {
        lcd.clear();
        lcd.print("Error b4 e31");
        lcd.setCursor(0, 1);

        lcd.setCursor(10, 1);
        lcd.print(vote15);
        delay(3000);
        lcd.clear();
        stat = 0;
      }
      else if (vote16 > vote13 && vote16 > vote14 && vote16 > vote15)
      {
        lcd.setCursor(0, 0);
        lcd.clear();
        lcd.print("Error B4 E32");
        lcd.print(vote16);
        delay(3000);
        lcd.clear();
        stat = 0;
      }


      else if (vote13 == 0 && vote14 == 0 && vote15 == 0 && vote16 == 0) {
        {
          lcd.clear();
          lcd.print(" Tie Up Or ");
          lcd.setCursor(0, 1);
          lcd.print(" No Result ");
          delay(3000);
          lcd.clear();
        }
      }
      lcd.print("System reset triggered");
      Serial.println("category 1");
      Serial.print("CD1  ");
      Serial.println(vote1);
      Serial.print("CD2  ");
      Serial.println(vote2);
      Serial.print("CD3  ");
      Serial.println(vote3);
      Serial.println("category 2");
      Serial.print("CD1  ");
      Serial.println(vote5);
      Serial.print("CD2  ");
      Serial.println(vote6);
      Serial.println("category 3");
      Serial.print("CD1  ");
      Serial.println(vote9);
      Serial.print("CD2  ");
      Serial.println(vote10);
      Serial.print("CD3");
      Serial.println(vote11);
      Serial.println("category 4");
      Serial.print("CD1 ");
      Serial.println(vote13);
      Serial.print("CD2  ");
      Serial.println(vote14);
      delay(750);
    }
    else
    {
      lcd.clear();
      lcd.print("No Voting....");
      stat = 0;
      delay(3000);
      lcd.clear();

    }
    vote13 = 0; vote14 = 0; vote15 = 0; vote16 = 0, votess = 0;
    lcd.clear();
  }
}

Have you considered the possibility that the button contacts are bouncing when you press it thus acting like multiple button presses ?

It really is time for you to learn about:
-functions
-arrays
-for loops
It is very difficult to check your code as it is full of stuff that should be somewhere else or is repeating all the time.
Yes, that will take time...
...but it will also increase your efficiency.

But UKHelibob might be right about bouncing. Maybe a simple 100nF capacitor from the input pin to ground could solve your problem...

For every input pin?
I know but I'm incredibly lazy.

I don't think so because when i click it once it registers it as one and not more than that
2 or more clicks brings the problem up

What is with this typo, I see this a lot on these forums

The problem is better illustrated with the full line of code

 if (stat == 1 ); {

It is not a typo but a deliberate use of the semicolon even though it should not be there

It no doubt happens because of the use of the semicolon to terminate program statements in C/C++, but it is totally inappropriate here at the end of the test expression

Yes, all input pins...
And you should not write to input pins...

Blockquote

digitalWrite(S1, HIGH);

Blockquote

You are allowed to be lazy, but do not expect us to actually solve your problems. We are here to help only.

Most of the time i just stitch together opinions to get a solution
All I'm looking for is some clues

i did some troubleshooting and found that the line
if (stat ==1); {
is actually the cause for wrong counting
I tried removing it but it just got worse.

You would probably want to remove the ; in that line.
The ; ends the conditional statement before it has done any actions (the code in between {}.