# 5.6 Unused variables

> A variable that is declared and never used, or written and never read, produces a warning: the program works, but something is left over.

Web page: https://pseudolearn.app/en/spec/declaraciones/sin-usar

> **In one sentence**
>
> A variable that is declared and never used, or written and never read, produces a warning: the program works, but something is left over.

## 5.6.1 How it works

The engine tells two oversights apart:

| Situation | Warning |
| --- | --- |
| declared and never used | `variableDeclaredNeverUsed` |
| assigned but never read | `variableAssignedNeverRead` |

Both are **warnings**: they do not prevent running. They usually point to a misspelt name, a result someone forgot to show or a leftover from an earlier version.

### Program: Two variables too many

```pseudolearn
Algorithm Limpieza
  Define usada As Integer <- 1;
  Define olvidada As Integer;
  Define escrita As Integer;
  escrita <- 5;
  Write usada;
EndAlgorithm
```

**Output**

```text
1
```

**Diagnostics**
- `variableDeclaredNeverUsed` (warning, 3:10): Variable declared but never used: olvidada
- `variableAssignedNeverRead` (warning, 4:10): Variable assigned but never read: escrita

*The program finishes normally.*

**Figure 5.6-1: Use of three variables**

A table with three variables. usada is written and read. olvidada is neither written nor read. escrita is written but not read.

Three variables and their use. Only the first is written and read.

Parameters and subprograms nobody uses have their own warnings, with the same idea.

**In short**
- Declaring and not using, or writing and not reading, produces a warning.
- Warnings do not prevent running.
- They usually point to a name mistake or a forgotten result.

**See also**
- [10.2 Severity and classes](https://pseudolearn.app/en/spec/diagnosticos/severidad.md)
- [5.1 Declaring variables with Define](https://pseudolearn.app/en/spec/declaraciones/definir.md)
