Combine two programs together on one bread board.

Hi Guys ;D

I've been months teaching my self and getting help on basic programming and l have come up with two that lm wishing to use on a project, but now hoping to combine them on the one bread board.
l have two button switches that control two separate sets of led.
Sketches are below that l wish to combine.
Thanks in advance

int switchPin = 3;              
int led1Pin = 10;
int led2pin = 11;

int val;                        
int val2;                       
int buttonState;               
int Mode = 0;             
boolean modeChanged = false;
const int NUM_MODES = 3;


void setup() {
    pinMode(switchPin, INPUT);    
    pinMode(led1Pin, OUTPUT);
    pinMode(led2pin, OUTPUT);
    buttonState = digitalRead(switchPin);  
}


void loop(){
    val = digitalRead(switchPin);     
    delay(10);                         // 
    val2 = digitalRead(switchPin);    
    if (val == val2) {                
        if (val != buttonState) {         
            if (val == LOW) {               
                Mode++;
                if (Mode >= NUM_MODES) {
                    Mode = 0;
                }
                modeChanged = true;
            }
        }
        buttonState = val;                 
    }

    if (modeChanged) {
        modeChanged = false;

        // Now do whatever the lightMode indicates
        switch(Mode) {
        case 0:
            digitalWrite(led1Pin, LOW);
            digitalWrite(led2pin, LOW);
            break;

        case 1:
            digitalWrite(led1Pin, HIGH);
            digitalWrite(led2pin, LOW);
            break;

        case 2:
            digitalWrite(led1Pin, LOW);
            digitalWrite(led2pin, HIGH);

      
        }
    }
}

int switchPin = 2;             
int led1Pin = 8;
int led2pin = 9;

int val;                       
int val2;                     
int buttonState;              
int Mode = 0;            
boolean modeChanged = false;
const int NUM_MODES = 3;     


void setup() {
    pinMode(switchPin, INPUT);    
    pinMode(led1Pin, OUTPUT);
    pinMode(led2pin, OUTPUT);
    buttonState = digitalRead(switchPin);  
}


void loop(){
    val = digitalRead(switchPin);      
    delay(10);                         
    val2 = digitalRead(switchPin);    
    if (val == val2) {               
        if (val != buttonState) {          
            if (val == LOW) {              
                Mode++;
                if (Mode >= NUM_MODES) {
                    Mode = 0;
                }
                modeChanged = true;
            }
        }
        buttonState = val;                
    }

    if (modeChanged) {
        modeChanged = false;

        // Now do whatever the lightMode indicates
        switch(Mode) {
        case 0:
            digitalWrite(led1Pin, LOW);
            digitalWrite(led2pin, LOW);
            break;

        case 1:
            digitalWrite(led1Pin, HIGH);
            digitalWrite(led2pin, LOW);
            break;

        case 2:
            digitalWrite(led1Pin, LOW);
            digitalWrite(led2pin, HIGH);

        case 3:
            digitalWrite(led1Pin, HIGH);
            digitalWrite(led2pin, HIGH);
        }
    }
}

Moderator edit: CODE TAGS.

I've been months teaching my self and getting help on basic programming and l have come up with two that lm wishing to use on a project

Really? Seems this code is straight from the Internet and you modified PINs values... That took months?

Well after l burnt 2 boards when learning and testing and trying, yes l did relate to a lot of help from the outside.
Being a senior i need all the help l can get.

Is is combining two programs into one sketch?

You have to change the variable names, so that each LED pins and Switch have different variable names. Then you can combine both.

This Simple Merge Demo may point you in the right direction.

...R

Thanks Robin2 l will have a look.

thanks sarouje