aniket chari, at first try a reset and a restore, see if that works, If that dos not work, you most likely will have to replace the digitizer. Follow this guide to work on it and the digitizer is available as a complete assembly right here as well as many other places. Hope this helps, good luck.
Includes the parts and tools to replace the touchscreen on your iPhone 3GS. Front panel does not include ear piece speaker and home button. Replace your cracked, broken, or shattered iPhone 3GS display. Compatible with all iPhone 3GS models. — 17 available at 14.95 each.