You need to export variable if they are to be used by processes other than the shell itself. Also, note that variable names are case sensitive - path is not the same as PATH.
Here program_1 cannot see myvar in the environment, but program_2 can.
You can do it all in one go like this:
Note that you will probably have to log out and back in again before variables which are set in your .bashrc are usable.