$echo $?
0
$echo $?
0
$exit 10 | tee solve.txt
$cat solve.txt 
$rm solve.txt 
$exit 10 | echo $?
0
$exit -1 | echo $?
0
$exit -1 | echo $?
0
$false | true
$echo $?
0
$false
$echo $?
1
$true
$echo $?
0
$exit 5 | tee var=$?
$file var\=0 
var=0: empty
$type var
bash: type: var: not found
$file var\=0 
var=0: empty
$

$trap $? > solve.txt exit 10
$cat solve.txt 
Display all 296 possibilities? (y or n)
$cat solve.txt 
$trap echo $? > solve.txt exit 10
$cat solve.txt 
$trap `echo $? > solve.txt` exit 10
$cat solve.txt 
0
$

$bash -c 'exit 7'; echo $?
7
$bash -c `exit 7`; echo $?
bash: -c: option requires an argument
2
$bash -c 'exit 7'; echo $?
7
$trap 'echo $? > solve.txt' exit 10
$cat solve.txt 
0
$cat solve.txt 
0
$bash -c 'exit 11'; echo $?
11
$