# Reading the return value of `main()` on the terminal

For example, compile and run the following:

```c
int main() { return 42; }
```

`42` becomes the exit code of the program. It is typically interpreted by the terminal as an error code, if the number is greater than 0. If the program ran successfully, it must return `0`.

If we avoid the `return`, then `main` automatically returns `0`.

::::{tab-set}
:::{tab-item} MacOS/Linux
```
echo $?
```
:::
:::{tab-item} Windows
```
$LASTEXITCODE
```
:::
::::

(hello-exit-code)=
:::{div}
You should see as output:
```
42
```
:::