A temporary variable is a variable in computer programming that has a short lifetime and is used to hold data that will be discarded soon or before it can be stored in a more permanent memory location. It is usually declared as a local variable, or a variable with local scope, because it is short-lived.