typhoid is a food and water borne disease. it is mainly associated with taking unhygienic road-side food and juice etc. try to carry your own tiffin and water to your office/college. this may not look cool , but will save you from lot of problems. whenever you eat outside ,try to have your meal in a clean and hygienic restaurant/hotel/dhaba. wash fruits and vegetables thoroughly before consumption. there are 2 typhoid vaccine available in india ( i recommend the injectable form ,typbar ), which can give you upto 70% immunity for 3 years.
as for pneumonia is concerned, it is usually caused by fine droplets like coughing , sneezing etc. it is one of the commonest communicable disease in India ,because of high population and overcrowding, hot and humid climate ,lack of personal and social etiquette etc. it is usually unavoidable unless you have very strong immunity .again,there are no medicines to build immunity, it is advised that you eat well and healthy and do exercise daily.
there are 2 injectable vaccines available for pneumonia too, one fights against 13 pneumonia causing bacteria (prevnar) . the other one( pneumovac) fights 23. so, you can use them. they are both quite safe and effective .
i advise all adults , who are not previously vaccinated,to get vaccinated with vaccine preventable diseases like hepatitis a and b, influenza,chicken pox,typhoid, pneumonia ,etc. i run an affordable adult vaccination package at my clinic and will soon put this package online on lybrate.
take care and be healthy.