R pull up

If I Connect switch. Why use R 10 k pull up? I just started to study. Thanks.

The input of the Arduino should be 0V (GND) or 5V. So the digitalRead() function will read LOW or HIGH. http://arduino.cc/en/Reference/digitalRead

The switch connects the Arduino pin to GND, but when the switch is open, the Arduino pin may not be unconnected and floating, it should be 5V. That is what the pullup resistor does, it pulls the pin to 5V.