How to Store Push Button Values?

This is the program which i found in Arduino Forum for Controlling a LED using a Push Button.
int ledPin = 12; // LED is connected to pin 12
int switchPin = 2; // switch is connected to pin 2
int val; // variable for reading the pin status

void setup() {
pinMode(ledPin, OUTPUT); // Set the LED pin as output
pinMode(switchPin, INPUT); // Set the switch pin as input

void loop(){
val = digitalRead(switchPin); // read input value and store it in val
if (val == HIGH) { // check if the button is pressed
digitalWrite(ledPin, LOW); // turn LED on
if (val == LOW) { // check if the button is not pressed
digitalWrite(ledPin, HIGH); // turn LED off

Now i would like to know how to store the value of the Button Input in Memory. For eg: If i press the Button it should store the value as HIGH and give the HIGH signal to LED and wait till i press the button again to Send LOW signal to LED. In simple words, it should turn ON and OFF the LED by remebering the Button Trigger

Define a variable which holds the current value of the LED (HIGH or LOW).

Each time a button press occurs, swap the value (of it was HIGH change it to LOW, if it was LOW change it to HIGH) and then write that value to the LED pin.