I want to install Ubuntu on a 4 gb pendrive but my cd writer is not working so I wnt it to install from the iso that I have downloaded. How to do that?
Pendrive as installation medium
It sounds like you want to use your pendrive as installation medium. You can achieve this easily by using a program called unetbootin (http://unetbootin.sourceforge.net/). You can install it from the Ubuntu Software Center (or the package manager interface of your choice) or by typing
sudo apt-get install unetbootin. If you are on Windows or Mac OS X right now, you can download it from the website.
To install the Ubuntu ISO on the pendrive just go through the steps provided by unetbootin. You probably need admin permissions on windows or root permission on Mac OS X or GNU/Linux.
Pendrive as installation target
If you really want to install Ubuntu to a pendrive (not using it as installation medium, but as "main harddrive" for your Ubuntu), one way is to simply install it to the pendrive via the regular installer. Theres another way providing some kind of hybrid mode between installation and Live-Medium, but I don't really know how this works.