Not all of these are correct programs to the questions but they are my personal attempt on it.