You know the mining reward is just a number in the code,what if a miner changed it?
It's possible you mean 1 of 2 things by "mining reward":
- Coinbase transaction.
Currently this reward is 25 bitcoins per block. If a miner changes this to be higher, it is an invalid block and other nodes will not accept this as a valid block. If the block is not accepted by other nodes, it doesn't go into the blockchain and the miner will not get any bitcoins.
The miner can change the reward to be lower than 25 bitcoins currently. This is potentially a way to slow down bitcoins coming into existence, but is otherwise not harmful. There is an economic disincentive for a miner to do this, but it is possible.
- Transaction fee.
This is the difference between the sum of the inputs and sum of the outputs in any given transaction. As the transaction is signed by a private key, any changes to either inputs or outputs will cause the signature embedded in the transaction to be invalid. If this transaction is included in a block, the block itself is invalid and will result in other nodes not accepting this block. Similarly as (1) the block being invalid will cause the block to not get into the blockchain causing the miner to not get any bitcoins.
Basically, the miner is heavily incentivized to act honestly as that's the only way a miner can get bitcoins.