You most likely will use train if you are planning trip to India. I should disappoint you if you are hoping to get train tickets when you’ll be in India. It is better to buy tickets in advance ff you want your trip to be without hassle. During my preparation I find out that tickets on some routes were sold out even two months in advance. So don’t wait till last minute.
The next question: where to buy these tickets? There is railway tickets reservation system (IRCTC) funded by Indian Government but is not very user friendly. Also you need to have Indian phone number as otherwise you won’t be able to register there.
The best site to make your tickets reservation is Cleartrip which is created with IRCTC association but looks much easier to use and there more search options which helps you faster to find tickets you need.
I hope this will help your trip planning and enjoy India.